# MC addChild / removeChild problem

**URL:** <https://forum.kirupa.com/t/mc-addchild-removechild-problem/286716>\
**Category:** flash\
**Created:** [April 20, 2009, 6:16am UTC](https://forum.kirupa.com/t/mc-addchild-removechild-problem/286716 "2009-04-20T06:16:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvouin](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@jvouin](https://forum.kirupa.com/u/jvouin)\
**Post date:** [April 20, 2009, 6:16am UTC](https://forum.kirupa.com/t/mc-addchild-removechild-problem/286716/1 "2009-04-20T06:16:04Z")

</div>

Hello I am doing a project in which I need to open AND CLOSE MovieClips.

I have my Scene1 which loads the first MC (named “page1”)  
then page1 plays and I would like it to unload itself and load the MC named “Page2”  
and so on up to page 10 …

On the last frame of the MC “page1” I have this code:

stop();

stage.addEventListener(MouseEvent.CLICK, animate2);

function animate2 (event:MouseEvent):void  
{  
stage.removeChild(stage.getChildByName(“clip1”));  
var clip2:MovieClip = new page2();  
addChild (clip2);  
}

but all I get is this error message:  
TypeError: Error #2007: Parameter child must be non-null.  
at flash.display::DisplayObjectContainer/removeChild()  
at page1/animate2()

Can anybody help me ???  
Thanks
