Reputation: 865
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)
Upvotes: 4
Views: 2409
Reputation: 4870
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.
Upvotes: 4
Reputation: 6307
Have you tried:
progress = event.bytesLoaded/event.bytesTotal;
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:)
Upvotes: 1