ProgressEvent.PROGRESS misreports bytesLoaded & bytesTotal

One problem you might run into involves ProgressEvent.PROGRESS events seeming to misreport the proportion of the file that has loaded.

This would cause a preloader’s bar to extend beyond the 100% mark. We don’t have time currently to outline the full technical context of the issue, but 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.

Add a comment:

*