Flash ProgressEvent 未显示总大小
我在 Flash 中使用 ProgressEvent 来确定下载某些内容需要多长时间。 我有这个:
progress = event.target.bytesLoaded/event.target.bytesTotal;
设置一个百分比。
经过一番摸索之后,我对这两个值进行了跟踪 - 结果发现“event.target.bytesTotal”始终等于零。
我在 Flex/AS3/Flash API 中找不到任何提及这一点的信息。 关于如何让 bytesTotal 工作有任何提示吗?
(我目前正在从网络服务器上的 PHP 文件中读取)
I'm using a ProgressEvent in Flash to determine how long something will take to download. I've got this:
progress = event.target.bytesLoaded/event.target.bytesTotal;
to set a percentage.
After some scratching of my head, I did a trace on the two values - and it turns out that "event.target.bytesTotal" is always equaling zero.
I can't find any mention of this in the Flex/AS3/Flash API. Any hints on how to get bytesTotal to work?
(I'm currently reading from a PHP file on the webserver)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们通过禁用某些文件类型的压缩在服务器上解决了这个问题。
对于正在压缩的文件,bytesTotal 为 0。 这种压缩是即时发生的,这就是服务器无法给出文件大小的原因(因为它还不知道)。 删除压缩解决了它。
We've solved this issue on our server by disabling the compression of some file types.
The bytesTotal was 0 for files that were being served compressed. This compression happens on-the-fly and that is why the server cannot give the size of the file (because it doesn't know it yet). Removing the compression solved it.
您是否尝试过:
bytesTotal / bytesLoaded 应该是进度事件的属性。
另外...我昨天遇到了这个问题,它完全困扰了我,直到我想到检查我正在加载的文件,它最终被损坏并且为 0 字节 - 所以也请仔细检查:)
Have you tried:
bytesTotal / bytesLoaded should be a property of the progress event.
Also... I had this problem yesterday, and it totally stumped me until I thought to check the file I was loading, and it ended up being corrupt and 0 bytes - so double check that too:)