Posted By

shuchii on 10/29/10


Tagged

image load


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

atalayyorukoglu
sexyflash
tspitzr
elkraneo


Load Image


 / Published in: ActionScript 3
 

Basic code snippet for loading an external image onto the stage.

  1. var imgLoader:Loader;
  2. var imgURL:String = "images/image1.jpg";
  3.  
  4. private function loadImage():void
  5. {
  6. imgLoader = new Loader();
  7. imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
  8. imgLoader.load( new URLRequest(imgURL) );
  9. }
  10.  
  11. private function imgLoaded(evt:Event):void
  12. {
  13. imgLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, imgLoaded);
  14. addChild(imgLoader);
  15. }

Report this snippet  

You need to login to post a comment.