About Orland MediaDevelopmentTrainingBlogRSS FeedContact us
Microphone

ProgressEvent.PROGRESS misreports bytesLoaded & bytesTotal

Date: Sunday 19th April 2009
Time: 13:35
Category: ActionScript 3.0
Views: 1,114
Comments: No 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.

Social bookmarks
  • Digg
  • Twitter
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Print
Rate this post
1 star2 stars3 stars4 stars5 stars   (3 votes, average: 3.33 out of 5)
Reply

Lenovo Microsoft Adobe Heart Internet Envirowise
Copyright © 2008 Orland Media Ltd | All rights reserved Company details Ethical policy Terms & conditions Privacy policy