# Unload(); is NOT working

**URL:** <https://forum.kirupa.com/t/unload-is-not-working/274206>\
**Category:** Uncategorized\
**Created:** [October 27, 2008, 2:41am UTC](https://forum.kirupa.com/t/unload-is-not-working/274206 "2008-10-27T02:41:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilt](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@gilt](https://forum.kirupa.com/u/gilt)\
**Post date:** [October 27, 2008, 2:41am UTC](https://forum.kirupa.com/t/unload-is-not-working/274206/1 "2008-10-27T02:41:27Z")

</div>

I’m trying to unload a loaded external .swf from a main.swf. I’ve read all the related threads but none seam to work for me.

What I’m doing seems pretty simple:  
One button loads an external .swf. into the main.swf. This works fine.  
Another button removes it. This is not working!

Here’s my code:

[COLOR=“red”]//This button loads an external .swf and works fine[/COLOR]  
mainNav.uidesign\_btn.addEventListener(MouseEvent.CLICK, uiDesign, false, 0, true);  
function uiDesign(evt:MouseEvent):void {  
//this loads external swf  
var request:URLRequest = new URLRequest(“ui.swf”);  
var loader:Loader = new Loader();  
loader.load(request);  
loader.x = 31;  
loader.y = 78;  
addChild(loader);  
//–end–this loads external swf  
}

[COLOR=“red”]//This is the button that SHOULD remove the .swf but does not work!![/COLOR]  
mainNav.home\_btn.addEventListener(MouseEvent.CLICK, home, false, 0, true);  
function home(evt:MouseEvent):void {

```
loader.unload()
removeChild( loader )

```

}

Someone PLEASE help me as I’ve spend most of today trying to figure this out.

Thank you all so much!!
