Posted By

dx0ne on 02/22/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

themill
tspitzr


AS3: Image load


 / Published in: ActionScript 3
 

  1. import flash.events.*;
  2. import flash.display.Loader;
  3. import flash.display.LoaderInfo;
  4. import flash.net.URLLoader;
  5. import flash.net.URLRequest;
  6.  
  7. var url:String = "http://domain.com/image.png";
  8. var myLoader:Loader;
  9. myLoader= new Loader();
  10. myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
  11. myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  12. myLoader.load(new URLRequest(url));
  13.  
  14. function onProgress(e:ProgressEvent):void
  15. {
  16. var p:Number = (e.bytesLoaded / e.bytesTotal);
  17. }
  18. function onComplete(e:Event):void
  19. {
  20. myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
  21. //e.target.content.bitmapData
  22. stage.addChild(myLoader);
  23. }

Report this snippet  

You need to login to post a comment.