# How do i remove the movieclips when i want to change screen?

**URL:** <https://forum.kirupa.com/t/how-do-i-remove-the-movieclips-when-i-want-to-change-screen/322096>\
**Category:** Uncategorized\
**Created:** [May 10, 2011, 5:47pm UTC](https://forum.kirupa.com/t/how-do-i-remove-the-movieclips-when-i-want-to-change-screen/322096 "2011-05-10T17:47:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glennyglenn0](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@glennyglenn0](https://forum.kirupa.com/u/glennyglenn0)\
**Post date:** [May 10, 2011, 5:47pm UTC](https://forum.kirupa.com/t/how-do-i-remove-the-movieclips-when-i-want-to-change-screen/322096/1 "2011-05-10T17:47:02Z")

</div>

I’ve hit a problem i cant fix, when i try and move from the roster screen to any of the other screens the items on the roster screen stay visible and the script on the new screen doesnt work.

My application is on the site below, please help!!

[http://www.mediafire.com/?92uwo97zv7nrn97](http://www.mediafire.com/?92uwo97zv7nrn97)

heres the code for the roster screen:

import fl.transitions.Tween;  
import fl.transitions.easing.\*;  
import fl.transitions.TweenEvent;

var columns:Number;  
var my\_x:Number;  
var my\_y:Number;  
var my\_thumb\_width:Number;  
var my\_thumb\_height:Number;  
var my\_images:XMLList;  
var my\_total:Number;  
var container\_mc:MovieClip;  
var full\_mc:MovieClip;  
var x\_counter:Number = 0;  
var y\_counter:Number = 0;

var myXMLLoader:URLLoader = new URLLoader();  
myXMLLoader.load(new URLRequest(“gallery.xml”));  
myXMLLoader.addEventListener(Event.COMPLETE, processXML);

function processXML (e:Event):void{

var myXML:XML = new XML(e.target.data);  
columns = myXML.@COLUMNS;  
my\_x = myXML.@XPOSITION;  
my\_y = myXML.@YPOSITION;  
my\_thumb\_width = myXML.@WIDTH;  
my\_thumb\_height = myXML.@HEIGHT;  
my\_images = myXML.IMAGE;  
my\_total = my\_images.length();

createContainer();  
callThumbs();

```
}

```

function createContainer():void{

container\_mc = new MovieClip();  
container\_mc.x = my\_x;  
container\_mc.y = my\_y;  
addChild(container\_mc);

container\_mc.addEventListener(MouseEvent.CLICK, callFull);  
container\_mc.addEventListener(MouseEvent.MOUSE\_OVER, onOver);  
container\_mc.addEventListener(MouseEvent.MOUSE\_OUT, onOut);  
container\_mc.buttonMode = true;

}

function callThumbs():void{

for (var i:Number = 0; i \< my\_total; i++){

var thumb\_url = my\_images\*.@THUMB;;  
var thumb\_loader = new Loader();  
thumb\_loader.load(new URLRequest(thumb\_url));  
thumb\_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);

thumb\_loader.name = i;

thumb\_loader.x = (my\_thumb\_width+10)\*x\_counter;  
thumb\_loader.y = (my\_thumb\_height+10)\*y\_counter;

if (x\_counter+1 \< columns){  
x\_counter++;  
} else {  
x\_counter = 0;  
y\_counter++;

}  
}

}

function thumbLoaded(e:Event):void{

var my\_thumb:Loader = Loader(e.target.loader);  
container\_mc.addChild(my\_thumb);  
new Tween(my\_thumb, “alpha”, Strong.easeIn, 0,1,0.5, true);  
}

function callFull(e:MouseEvent):void{

var full\_loader:Loader = new Loader();  
var full\_url = my\_images[e.target.name].@FULL;  
full\_loader.load(new URLRequest(full\_url));  
full\_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded);

container\_mc.removeEventListener(MouseEvent.CLICK, callFull);  
container\_mc.buttonMode = false;  
container\_mc.removeEventListener(MouseEvent.MOUSE\_OVER, onOver);  
container\_mc.removeEventListener(MouseEvent.MOUSE\_OUT, onOut);  
new Tween(container\_mc, “alpha”, Strong.easeIn, 1,0.5,0.5, true);  
}

function fullLoaded(e:Event):void{

full\_mc = new MovieClip();  
full\_mc.buttonMode = true;  
addChild (full\_mc);

var my\_loader:Loader = Loader(e.target.loader);  
full\_mc.addChild(my\_loader);  
new Tween(my\_loader, “alpha”, Strong.easeIn, 0,1,0.5, true);  
my\_loader.x = 0;  
my\_loader.y = 10;  
my\_loader.addEventListener(MouseEvent.CLICK,removeFull);  
}

function removeFull(e:MouseEvent):void{

var my\_loader:Loader = Loader (e.currentTarget);  
var fade\_out:Tween = new Tween(my\_loader, “alpha”, Strong.easeOut, 1,0,0.5, true);  
fade\_out.addEventListener(TweenEvent.MOTION\_FINISH, tweenFinished);

new Tween(container\_mc, “alpha”, Strong.easeOut, 0.5,1,0.5, true);  
}

function tweenFinished (e:TweenEvent):void{

var my\_loader:Loader = Loader (e.target.obj);  
my\_loader.unload();  
full\_mc.removeChild(my\_loader);  
removeChild(full\_mc);  
full\_mc = null;

container\_mc.addEventListener(MouseEvent.CLICK, callFull);  
container\_mc.buttonMode = true;  
container\_mc.addEventListener(MouseEvent.MOUSE\_OVER, onOver);  
container\_mc.addEventListener(MouseEvent.MOUSE\_OUT, onOut);

}

function onOver (e:MouseEvent):void{

var my\_thumb:Loader = Loader(e.target);  
my\_thumb.alpha = 0.5;

}

function onOut (e:MouseEvent):void{

var my\_thumb:Loader = Loader (e.target);  
my\_thumb.alpha = 1;

}
