Posted By

tuffstudio on 11/26/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tspitzr


Preloader & Progress Structure


 / Published in: ActionScript 3
 

URL: www.tuff-studio.com

  1. var loader:Loader = new Loader();
  2. var request:URLRequest;
  3. var percent:Number;
  4.  
  5. prelo("path_to_a_file"); //// function that starts loading passed item
  6.  
  7. function prelo(path:String):void
  8. {
  9. request = new URLRequest(path);
  10. loader.load(request);
  11. addChild(loader);
  12.  
  13. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
  14. loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
  15. }
  16.  
  17. function showProgress(event:ProgressEvent):void ///////////// display progress animation
  18. {
  19. percent = Math.round((event.bytesLoaded / event.bytesTotal )*100 );
  20. ///////// if text file used
  21. //PercentText.text = percent + "%";
  22. }
  23.  
  24. function onLoaded(event:Event):void /////////// when content is loaded
  25. {
  26. /// content loaded !!!
  27.  
  28. }

Report this snippet  

You need to login to post a comment.