ProgressEvent.PROGRESS misreports bytesLoaded & bytesTotal
Date: Sunday 19th April 2009
Time: 13:35
Category: ActionScript 3.0
Views: 728
Comments:
One problem we recently ran into involved ProgressEvent.PROGRESS events seeming to misreport the proportion of the file that has loaded.
This would cause the preloader’s bar to extend beyond the 100% mark. While we don’t have time currently to outline the full technical context of the issue, we did spend some time examining it, and we solved it.
The solution to the problem was not to use the bytesLoaded and bytesTotal of the actual ProgressEvent in the event listener, but to instead use the properties of the target (which is a LoaderInfo object). So your code looks like this:
private function update(e:ProgressEvent):void
{
// causes misreport:
// var bt:uint = e.bytesTotal;
// var bl:uint = e.bytesLoaded;
// prevents misreport:
var bt:uint = e.target.bytesTotal;
var bl:uint = e.target.bytesLoaded;
bar.scaleX = bl/bt;
}
We’ll try to expand on this issue at a later time. In the meantime we hope this helps someone.

/rating_start.png)
/rating_on.png)
/rating_on.png)
/rating_on.png)
/rating_half.png)
/rating_off.png)
(3 votes, average: 3.33 out of 5)