# Removechild dramas

**URL:** <https://forum.kirupa.com/t/removechild-dramas/259242>\
**Category:** Uncategorized\
**Created:** [May 2, 2008, 12:53pm UTC](https://forum.kirupa.com/t/removechild-dramas/259242 "2008-05-02T12:53:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dredd\_controls](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@dredd\_controls](https://forum.kirupa.com/u/dredd_controls)\
**Post date:** [May 2, 2008, 12:53pm UTC](https://forum.kirupa.com/t/removechild-dramas/259242/1 "2008-05-02T12:53:13Z")

</div>

I am adding two buttons to the stage. Clicking the first button loads four movieclips to the stage. Clicking the second button removes them. This all works fine once then it crashes. It keeps coming up with an error

TypeError: Error #2007: Parameter child must be non-null.  
at flash.display::DisplayObjectContainer/removeChild()  
at test2\_fla::MainTimeline/retractMenu()

Do not know how to resolve this, can someone point me in the right direction.

import fl.transitions.easing._;  
import flash.events._;  
import flash.utils.\*;

var menuopen = false;  
var menuButs = [];

var tab\_mc = new menutab\_mc();  
addChild(tab\_mc);  
tab\_mc.x = 100;  
tab\_mc.y = 200;  
tab\_mc.addEventListener(MouseEvent.MOUSE\_DOWN,launchMenu);

var tab\_mc2 = new menutab\_mc();  
addChild(tab\_mc2);  
tab\_mc2.x = 50;  
tab\_mc2.y = 200;  
tab\_mc2.addEventListener(MouseEvent.MOUSE\_DOWN,retractMenu);

function launchMenu(event:Event):void{  
trace(menuopen);  
for(var a = 0 ; a \< 4 ; a++){  
var box = new menuBtn();  
this.addChild(box);  
menuButs.push(box);  
box.x = 165+ (166 \* a);  
box.y = 200;  
}

}  
function retractMenu(event:Event):void{  
for(var a = 0; a \< menuButs.length; a++){  
this.removeChild(menuButs[a]);  
menuButs[a] = null;  
}   
}
