Flash Preloader,如何判断是否处于 gzip 压缩环境中并进行相应加载

发布于 2024-12-05 06:11:30 字数 311 浏览 0 评论 0原文

闪存预加载器可能会遇到两种状态。
1) 总字节数已知(swf 的最终文件大小)
2) 总字节数未知(如果服务器正在压缩服务/输出文件,则会发生此情况)。

我目前使用totalBytes == 0(Chrome,Safari),swf是不确定的,只是显示一个循环动画,并显示loadedBytes。
然而,在 Firefox 中,totalBytes == returnedBytes。我只能推测这样做是为了防止预加载器尝试确定下载百分比时出现大量除以零的异常。

问题:
是否有其他方法可以确定我所处的预加载状态(确定文件大小或不确定文件大小)?

There are two states a flash preloader can encounter.
1) The totalBytes is known (the final filesize of the swf)
2) The totalBytes is unknown (Occurs if the server is compression the served/output files).

I currently use totalBytes == 0 (Chrome, Safari) that the swf is indeterminate and simply show a looping animation with loadedBytes displayed.
HOWEVER in Firefox totalBytes == loadedBytes. I can only surmise this was done to prevent a lot of divide by zero exceptions when the preloader tries to determine the percent downloaded.

The issue:
Is there any other means to determine in which preloading state (determinate filesize or indeterminate filesize) that I am in?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瞳孔里扚悲伤 2024-12-12 06:11:30

如果 apache 压缩或 gzip 来自服务器的所有流量,则 swf 文件会丢失有关其文件大小的信息。检查totalBytes 值,该值通常应为swf 文件的大小,如果它为零,则说明它处于gzip 压缩环境中。

if (loaderInfo.totalBytes == 0) // gzipped environment

然而,需要对 Firefox 进行特殊情况检查,因为 Firefox 设置了totalBytes == returnedBytes。

if (loaderInfo.totalBytes == loaderInfo.loadedBytes) // gzipped environment
// OR the loaded swf is very small.
// check the load is COMPLETE Event, if !loadComplete than gzipped environment

If apache compresses or gzips all traffic from the server, the swf file loses information on its filesize. Check the totalBytes value which should normally be the size of the swf file, if it is zero then it's in a gzipped environment.

if (loaderInfo.totalBytes == 0) // gzipped environment

However a special case check needs to be done for Firefox, since firefox sets the totalBytes == loadedBytes.

if (loaderInfo.totalBytes == loaderInfo.loadedBytes) // gzipped environment
// OR the loaded swf is very small.
// check the load is COMPLETE Event, if !loadComplete than gzipped environment
沙沙粒小 2024-12-12 06:11:30

我推荐你使用LoaderMAX。因为它加载外部文件非常简单易用。检查这个

i recommend you to use LoaderMAX. because it's so simple and easy to use for loading external files. check this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文