# Unloading an external swf with child

**URL:** <https://forum.kirupa.com/t/unloading-an-external-swf-with-child/271236>\
**Category:** flash\
**Created:** [September 20, 2008, 2:17am UTC](https://forum.kirupa.com/t/unloading-an-external-swf-with-child/271236 "2008-09-20T02:17:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dragonred7](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@dragonred7](https://forum.kirupa.com/u/dragonred7)\
**Post date:** [September 20, 2008, 2:17am UTC](https://forum.kirupa.com/t/unloading-an-external-swf-with-child/271236/1 "2008-09-20T02:17:01Z")

</div>

Ok I have been racking my brain and the web for the answer to this.

Here’s the code:

//Variable for the swfLoader  
var swfLoader:Loader = new Loader();

//Variables that load the swf movies  
var loadMain:URLRequest = new URLRequest(“Main.swf”);  
var loadTrips:URLRequest = new URLRequest(“Trips.swf”);

//Load the Main page  
swfLoader.load(loadMain);  
addChild(swfLoader);

//Home button  
function goHome(event:MouseEvent):void {  
swfLoader.load(loadMain);  
addChild(swfLoader);  
}

//Trips button  
function goTrips(event:MouseEvent):void {  
swfLoader.load(loadTrips);  
addChild(swfLoader);  
}

//Event listener  
btnHome.addEventListener(MouseEvent.CLICK, goHome);  
btnTrips.addEventListener(MouseEvent.CLICK, goTrips);

The problem is the trip.swf has clips that have been added using addChild(). When I click the home button it loads the main.swf but the child clips from trip.swf stay on the stage. The swf itself is unloaded but not its children. I hope this makes sense and someone can help.

Thanks,  
dragonred7
