# Problem unloading SWF

**URL:** <https://forum.kirupa.com/t/problem-unloading-swf/303516>\
**Category:** flash\
**Created:** [January 21, 2010, 2:46pm UTC](https://forum.kirupa.com/t/problem-unloading-swf/303516 "2010-01-21T14:46:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdahlstrom](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kdahlstrom](https://forum.kirupa.com/u/kdahlstrom)\
**Post date:** [January 21, 2010, 2:46pm UTC](https://forum.kirupa.com/t/problem-unloading-swf/303516/1 "2010-01-21T14:46:47Z")

</div>

Trying to unload a swf via clicking a button, when i exit the frame the previous swf is still there under the new frame. Any ideas

—Button code—

stop();

function onIntro9Click(evt:MouseEvent):void {  
gotoAndPlay(1);  
}

intro9\_btn.addEventListener(MouseEvent.CLICK, onIntro9Click);

----Loading and Unloading the SWF----

//-----------------------LOADING THE GALLERY--------------------//  
var ld:Loader = new Loader();  
var gal:DisplayObject;  
ld.load(new URLRequest(“present.swf”));  
ld.contentLoaderInfo.addEventListener(Event.INIT, loadingDone);

function loadingDone(e:Event):void{  
gal = e.target.content  
addChildAt(gal,0);  
}  
//------------------------------------------------------------------//

//-------------------UNLOADING THE GALLERY---------------------------//  
unload\_mc.addEventListener(MouseEvent.CLICK,unloadGal);

function unloadGal(e:MouseEvent):void{  
removeChild(gal);  
}  
//-------------------------------------------------------------------//
