removeChild

Hi,

Im building a Video ondemand site, im using a movieclip “thisMC” to load flv videos and when a button in the main timeline is pressed it should unload and clear the screen.

it works fine with the objects on the timeline, but i want to remove a child which is called by a another Object (a Movieclip).

The Child is called by “mc_loading” Movie Clip but then i try to remove the child using a script in the main timeline it doesnt work.

i’ve used MovieClip(root).removeChild(thisMC) and stage.removeChild(thisMC);

Any help is appriciated im still new to AS3

Thanks

You should never let a child remove a child in its parent.

What you can do is have the parent listen to an event of your choice say;

addEventListener(“GO_FOR_IT”, functionToDeleteChild);

and in the child you can do a
dispatchEvent(new Event(“GO_FOR_IT”));

when you need to remove it.

Hey thanks for the reply sekasi but im a bit confused on where to put that code… il explain my situation a bit further…

[U]This is the code for the button in “loading_mc” MovieClip
[/U]
btnOn.addEventListener(MouseEvent.MOUSE_DOWN, tvon);

function tvon (event:Event):void{
SoundMixer.stopAll();
thisLoader.unload();
**removeChild(thisMC);
** gotoAndStop(16);
removeEventListener(MouseEvent.MOUSE_DOWN, tvon);
}

[U]this is the code in the another movie clip “scroll” used to load the swf’s and add the child

[/U]// Tell AS that the loaded file is a movie clip and add it to the stage.
function doneLoading(e:Event):void {
thisMC = MovieClip(thisLoader.content);
thisLoader.unload();
MovieClip(root).addChild(thisMC);
thisMC.x=391;
thisMC.y=185;
thisMC.play();
removeEventListener(Event.INIT, doneLoading, true);
}
both of these are in the main timeline in different layers…

Hope its clear now…

Thanks