Posted By

adrianparr on 04/14/10


Tagged

size formatted progress as3 total bytes mb loaderInfo loaded bytestotal bytesloaded megabytes progressevent


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

socialflasher
Nikolai
tspitzr


AS3 Display BytesTotal as Megabytes (formatted)


 / Published in: ActionScript 3
 

  1. var bytesTotal:int = loaderInfo.bytesTotal;
  2.  
  3. var kbFormatted:String = Math.floor(bytesTotal/1024)+" KB";
  4. var mbFormatted:String = (Math.floor(((bytesTotal/1024/ 1024)*100))/100)+" MB";
  5.  
  6. trace("kbFormatted: "+kbFormatted);
  7. trace("mbFormatted: "+mbFormatted);
  8.  
  9. // For example, if bytesTotal = 5024322 the output would be ...
  10. // kbFormatted: 4906 KB
  11. // mbFormatted: 4.79 MB

Report this snippet  

You need to login to post a comment.