# AS3 load and unload image

**URL:** https://forum.kirupa.com/t/as3-load-and-unload-image/325939
**Category:** flash
**Created:** [November 12, 2011, 11:06pm UTC](https://forum.kirupa.com/t/as3-load-and-unload-image/325939 "2011-11-12T23:06:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![RJC](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@RJC](https://forum.kirupa.com/u/RJC)
#### Post date: [November 12, 2011, 11:06pm UTC](https://forum.kirupa.com/t/as3-load-and-unload-image/325939/1 "2011-11-12T23:06:27Z")

</div>

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 🙂  
}
