Flash Preloader,如何判断是否处于 gzip 压缩环境中并进行相应加载
闪存预加载器可能会遇到两种状态。
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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 apache 压缩或 gzip 来自服务器的所有流量,则 swf 文件会丢失有关其文件大小的信息。检查totalBytes 值,该值通常应为swf 文件的大小,如果它为零,则说明它处于gzip 压缩环境中。
然而,需要对 Firefox 进行特殊情况检查,因为 Firefox 设置了totalBytes == returnedBytes。
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.
However a special case check needs to be done for Firefox, since firefox sets the totalBytes == loadedBytes.
我推荐你使用LoaderMAX。因为它加载外部文件非常简单易用。检查这个
i recommend you to use LoaderMAX. because it's so simple and easy to use for loading external files. check this