This code posted on this site is great for loading an external image on entering a frame but how do I unload that image on leaving the frame?
var imageLoader:Loader;
function loadImage(url:String):void {
// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}
loadImage(“run.jpg”);
function imageLoaded(e:Event):void {
// Load Image
runMC.addChild(imageLoader);
}
function imageLoading(e:ProgressEvent):void {
// Use it to get current download progress
// Hint: You could tie the values to a preloader
}