R – Flash ProgressEvent Not Showing Total Size

actionscript-3fileflashprogresssize

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)

Best Solution

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