Posted By

arpo on 08/31/09


Tagged


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

toxin20
KDR
quan
davidino1978


load multiple images


 / Published in: ActionScript 3
 

  1. var imagePath:Array = ["image1.jpg", "image2.jpg", "image3.jpg"];
  2. var imageArr:Array = new Array();
  3. loadImage(imagePath[0]);
  4.  
  5. function loadImage(img:String):void {
  6. var imageLoader:Loader = new Loader();
  7. imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
  8. imageLoader.load(new URLRequest(imagePath[0]));
  9. }
  10.  
  11. function loadComplete(e:Event):void {
  12. imageArr.push(e.target.content);
  13. imagePath.shift();
  14. addChild(imageArr[imageArr.length - 1]);
  15. if (imagePath.length > 0) {
  16. loadImage(imagePath[0]);
  17. }
  18. }

Report this snippet  

You need to login to post a comment.