I’ve built a basic image gallery which has multiple thumbnails/objects which calls a common displayImage class object with a shared preloader to load the image.
The problem is that when the user decides to click on another or multiple thumbnails before the current preloader completes, i expected that the new call would override and interupt the ongoing load() container and preload the last image clicked, instead it seems to add to the ongoing load() object leading to wacky results (like having a loadedPercent values over 100% and the other images being loaded up instead). What’s going on? I’ve tried to nullify the ongoing load() object everytime it calls a new image, but to no avail…
public function loadImage(url:URLRequest) {
try{imgLoader.close();}catch(error:Error) {};
imgLoader.unload();
imgLoader = null;
imgLoader = new Loader();
imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
imgLoader.load(url);
}
is there a better way to go about this?