# Unloading a dynamic movieclip?

**URL:** <https://forum.kirupa.com/t/unloading-a-dynamic-movieclip/260859>\
**Category:** Uncategorized\
**Created:** [May 20, 2008, 3:03pm UTC](https://forum.kirupa.com/t/unloading-a-dynamic-movieclip/260859 "2008-05-20T15:03:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![split67](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/split67/32/2089_2.png) [@split67](https://forum.kirupa.com/u/split67)\
**Post date:** [May 20, 2008, 3:03pm UTC](https://forum.kirupa.com/t/unloading-a-dynamic-movieclip/260859/1 "2008-05-20T15:03:36Z")

</div>

I’m having issues figuring out this once simple command. Below is my code, how can i create an unload function that works for all my buttons? I’ve been researching but can’t find something clear enough for me to understand. I feel like there’s an easy fix, but i’m fried from staring at it. Thanks!

var home:Loader = new Loader();  
var contact:Loader = new Loader();  
var cont:MovieClip = new MovieClip();

//1st button:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  
home\_btn.addEventListener(MouseEvent.MOUSE\_OVER, homeOver);  
function homeOver(evt:MouseEvent):void {  
home\_btn\_mc.gotoAndPlay(“on”);  
}  
home\_btn.addEventListener(MouseEvent.CLICK, homeLoad);

```
function homeLoad(Event: MouseEvent) {
    home.load(new URLRequest("home.swf"));
    cont.x = 0;
    cont.y = 20;
    stage.addChild(cont);
    cont.addChild(home);
}

```

home\_btn.addEventListener(MouseEvent.MOUSE\_OUT, homeOut);  
function homeOut(evt:MouseEvent):void {  
home\_btn\_mc.gotoAndPlay(“off”);  
}

//2nd button:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  
contact\_btn.addEventListener(MouseEvent.CLICK, contactLoad);  
function contactLoad(Event: MouseEvent) {  
contact.load(new URLRequest(“contact.swf”));  
cont.x = 0;  
cont.y = 20;  
stage.addChild(cont);  
cont.addChild(contact);  
}

contact\_btn.addEventListener(MouseEvent.MOUSE\_OVER, contactOver);  
function contactOver(evt:MouseEvent):void {  
contact\_btn\_mc.gotoAndPlay(“on”);  
}

contact\_btn.addEventListener(MouseEvent.MOUSE\_OUT, contactOut);  
function contactOut(evt:MouseEvent):void {  
contact\_btn\_mc.gotoAndPlay(“off”);  
}

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [May 20, 2008, 10:21pm UTC](https://forum.kirupa.com/t/unloading-a-dynamic-movieclip/260859/2 "2008-05-20T22:21:14Z")

</div>

u can use one loader.  
it is enough to add cont once  
u should avoid adding clips to stage, instead u should use root

```auto
root.addChild(cont);

```

to unload just call

```auto
loader.unload();

```

if u want really fast reuse clips, u don’t have to unload them just remove loader from DisplayList. But remember that if u can’t see that content u shouldn’t forget that it is still playing.

```auto
removeChild(loader);

```
