# Interactive CD - Load and unload problems

**URL:** <https://forum.kirupa.com/t/interactive-cd-load-and-unload-problems/325703>\
**Category:** flash\
**Created:** [October 31, 2011, 6:53pm UTC](https://forum.kirupa.com/t/interactive-cd-load-and-unload-problems/325703 "2011-10-31T18:53:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevie7](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stevie7](https://forum.kirupa.com/u/stevie7)\
**Post date:** [October 31, 2011, 6:53pm UTC](https://forum.kirupa.com/t/interactive-cd-load-and-unload-problems/325703/1 "2011-10-31T18:53:33Z")

</div>

I know this is probably a basic error I am making but I am really lost!

Please help if you can!

I am creating an interactive CD but the same files will be used online.

I have a menu that loads in a swf to sit on top of everything. In this movie I have a quit button. When I click this I want to close this top swf and reveal the swf beneath again.

I have managed to get the “quit button” to load in the menu swf again but it seems to me that it is loading in a second version of this as opposed to taking away the loaded movie.

The code I have used for this is:

* * *

quit\_mc.addEventListener(MouseEvent.CLICK, fl\_ClickToLoadUnloadSWF\_2);

var fl\_Loader\_2:Loader;

//This variable keeps track of whether you want to load or unload the SWF  
var fl\_ToLoad\_2:Boolean = !fl\_ToLoad\_2;

function fl\_ClickToLoadUnloadSWF\_2(event:MouseEvent):void  
{  
if(fl\_ToLoad\_2)  
{  
fl\_Loader\_2 = new Loader();  
fl\_Loader\_2.load(new URLRequest(“fscommand/early.swf”));  
addChild(fl\_Loader\_2);  
SoundMixer.stopAll();

```
}
else
{
    fl_Loader_2.unload();
    removeChild(fl_Loader_2);
    fl_Loader_2 = null;
    SoundMixer.stopAll();
    
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad_2 = !fl_ToLoad_2;

```

## }

I know this is not right but I can’t figure out how to do it properly.

What I am really trying to do is replace each movie with the loaded movie.

For example Movie 1 - has a menu in it. Clicking on Movie 2 menu option removes Movie 1 and replaces it with Movie 2.

Clicking on the “Quit” button in movie 2 would remove movie 2 and replace it with movie 1 again.

Any help is greatly appreciated!

Stevie
