# removeChild

**URL:** <https://forum.kirupa.com/t/removechild/265448>\
**Category:** Uncategorized\
**Created:** [July 9, 2008, 2:37am UTC](https://forum.kirupa.com/t/removechild/265448 "2008-07-09T02:37:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 2:37am UTC](https://forum.kirupa.com/t/removechild/265448/1 "2008-07-09T02:37:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [July 9, 2008, 2:51am UTC](https://forum.kirupa.com/t/removechild/265448/2 "2008-07-09T02:51:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![flashhash](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@flashhash](https://forum.kirupa.com/u/flashhash)\
**Post date:** [July 9, 2008, 3:04am UTC](https://forum.kirupa.com/t/removechild/265448/3 "2008-07-09T03:04:18Z")

</div>

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
