Hello,
I am trying to load images and when the loading is complete I want to make each image a separate Movie Clip for further manipulation. I have the loading code down, but when I have more than one image only the last image loaded is shown and the first image is nowhere to be found.
Here’s the code:
function loadImage(url:String):void{
preloader.visible = true;
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imageNotFound);
}
function imageNotFound(e:IOErrorEvent){
trace("Image not found.");
preloader.percentage.text = "File not found.";
}
function imageLoading(e:ProgressEvent){
var loaded = e.bytesLoaded / e.bytesTotal;
preloader.SetProgress(loaded);
}
function imageLoaded(e:Event){
numImages += 1;
**var pic = imagesArray[numImages] = imageParent.addChild(imageLoader); //this part is what I need help with**
pic.x = (windowWidth-275)/2;
pic.y = 28;
pic.alpha = 0;
preloader.visible = false;
}
i think it has something to do with the fact that I am not using the new function somewhere, but I do not know how to use that in the code to make it work.
(Here’s the tutorial I’m expanding on: http://www.kirupa.com/developer/flashcs3/preloader_as3_pg1.htm )
Thanks!