So I’m working on an image gallery that preloads each image before it adds it on the stage. I got that to work great. The problem I’m having is that I also made it so there’s more than one album of images. So sometimes if I click “Next Album” or whatever, there will still be an image in limbo that’s loading from the previous album, and that one will come up on the stage in the wrong album. So I was hoping there would be a way to cancel it some how?
Here’s a small portion of how I’m doing it:
function displayProjectImages():void
{
var projectImageURL:String;
var displayImageLoader:Loader;
projectImageURL = displayProjectXML.images.image[_imgLoadIndex];
displayImageLoader = new Loader();
displayImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadComplete);
displayImageLoader.load(new URLRequest(projectImageURL));
}
function imageLoadComplete(event:Event):void
{
var displayImageLoader:* = event.target.content;
projectDetailsTemp.containerImages.addChild(displayProjectImage);
displayProjectImage.addChild(displayImageLoader);
displayProjectImageList.push(displayImageLoader);
_imgLoadIndex++;
if (_imgLoadIndex<_projectDetailsImagesLength) {
displayProjectImages();
}
}
So that’s how I load the images. If I click to see the next album, I call a function that removes the child of where the images and content are in, clear the array of displayProjectImageList and change _imgLoadIndex to 0. I tried removing the listener as well as tons of other things but still no luck.
Any help would be greatly appreciated!