# Load and Unload SWF

**URL:** <https://forum.kirupa.com/t/load-and-unload-swf/256104>\
**Category:** flash\
**Created:** [March 30, 2008, 8:21pm UTC](https://forum.kirupa.com/t/load-and-unload-swf/256104 "2008-03-30T20:21:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LauraITT](https://avatars.discourse-cdn.com/v4/letter/l/82dd89/32.png) [@LauraITT](https://forum.kirupa.com/u/LauraITT)\
**Post date:** [March 30, 2008, 8:21pm UTC](https://forum.kirupa.com/t/load-and-unload-swf/256104/1 "2008-03-30T20:21:10Z")

</div>

Hey,

This is the code I have so far, it opens the BonesInsideCastle.swf but it doesnt unload the first swf … Any idea’s ??

```php
stop(); 
Castle.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown); 
function mouseDown(event:MouseEvent):void {   
if (event.target == Castle) { 
     
var myrequest:URLRequest=new URLRequest("BonesInsideCastle.swf");      
var myloader:Loader=new Loader();  
myloader.load(myrequest);      
stage.addChild(myloader); } }// and the unloadFunction function  

var myloader:Loader=new Loader();  
myloader.unload(); 
myloader.addEventListener("Unloadme", unloadFunction);  
function unloadFunction(event:Event):void {  
// event.target is the loader reference.. so cast it as Loader   
Loader(event.currentTarget).unload(); }

```

Thanks in advance  
[COLOR=#000000][COLOR=#007700] [/COLOR][/COLOR]
