# Unload external swf and load new one?

**URL:** https://forum.kirupa.com/t/unload-external-swf-and-load-new-one/180554
**Category:** Uncategorized
**Created:** [March 1, 2006, 2:31pm UTC](https://forum.kirupa.com/t/unload-external-swf-and-load-new-one/180554 "2006-03-01T14:31:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sebus](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sebus](https://forum.kirupa.com/u/sebus)
#### Post date: [March 1, 2006, 2:31pm UTC](https://forum.kirupa.com/t/unload-external-swf-and-load-new-one/180554/1 "2006-03-01T14:31:32Z")

</div>

i want to setup my portfolio so I don’t have to create separate scenes. So basically, I wan to have several buttons, if you click one it loads an external SWF, if you click the next it “unloads?” the first swf and loads the next one… I know how to load external swf’s but is there anyway to unload it and load the next ? thanks in advance.

---

<div class="post-metadata">

### Author: ![MeyeZor](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@MeyeZor](https://forum.kirupa.com/u/MeyeZor)
#### Post date: [June 24, 2008, 3:42pm UTC](https://forum.kirupa.com/t/unload-external-swf-and-load-new-one/180554/2 "2008-06-24T15:42:46Z")

</div>

[quote=lunatic;1787538]You know that if you are using an empty movieclip to load external swfs into then you don’t have to unload before loading a new one in right? If you load a 2nd external into a container clip it will replace whatever was there before.

If you are loading externals into different levels then yes you’ll have to unload to remove the previous swf.[/quote]

Can you show me an example. I’m having this issue mostly because of my lack of action scripting skillz. Im trying to do this in as3…

Here is what I have so far… and as you can see the swf loads on top of the last loaded swf but leaving the first one there.

//  
function homeButton(myevent:MouseEvent):void{  
var myrequest:URLRequest=new URLRequest(“zzz.swf”);  
var myloader:Loader=new Loader();  
myloader.unload();  
myloader.load(myrequest);  
stage.addChild(myloader);  
myloader.x=420;  
myloader.y=250;  
}

home\_btn.addEventListener(MouseEvent.CLICK, homeButton);  
//  
//  
function printButton(myevent:MouseEvent):void{  
var myrequest:URLRequest=new URLRequest(“xxx.swf”);  
var myloader:Loader=new Loader();  
myloader.unload();  
myloader.load(myrequest);  
stage.addChild(myloader);  
myloader.x=420;  
myloader.y=250;  
}

print\_btn.addEventListener(MouseEvent.CLICK, printButton);  
//
