views:

534

answers:

2

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)

A: 

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:)

quoo
Hm, your code produces the exact same effect (bytesLoaded works fine, bytesTotal always reports 0). I know the file is fine because it eventually downloads and works. :)
Andy Moore
Really strange. If you try the code with another php file, or something else, does it do the same thing?
quoo
If you check the urlloader.bytesTotal (or whatever you're using) property of whatever you're loading, is that also zero?
quoo
Maybe the file you're loading doesn't have Content-Length header set somehow?
radekg
A: 

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.

frankhermes