We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Posted By

zeman on 07/10/08


Tagged

jpg png gif textmate load swf loader


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

visuallyspun
taboularasa
abdsign


Loader


Published in: ActionScript 3 


  1. var request:URLRequest = new URLRequest("image.jpg");
  2. var loader:Loader = new Loader();
  3.  
  4. loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
  5. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
  6.  
  7. function loadProgress(event:ProgressEvent):void {
  8. var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
  9. percentLoaded = Math.round(percentLoaded * 100);
  10. trace("Loading: "+percentLoaded+"%");
  11. }
  12.  
  13. function loadComplete(event:Event):void {
  14. trace("Complete");
  15. }
  16.  
  17. loader.load(request);
  18. addChild(loader);

Report this snippet 

You need to login to post a comment.