# Remove Children

**URL:** <https://forum.kirupa.com/t/remove-children/327709>\
**Category:** flash\
**Created:** [March 21, 2012, 8:44pm UTC](https://forum.kirupa.com/t/remove-children/327709 "2012-03-21T20:44:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![littlea5h](https://avatars.discourse-cdn.com/v4/letter/l/3e96dc/32.png) [@littlea5h](https://forum.kirupa.com/u/littlea5h)\
**Post date:** [March 21, 2012, 8:44pm UTC](https://forum.kirupa.com/t/remove-children/327709/1 "2012-03-21T20:44:28Z")

</div>

So i have a calculator and converter on two different scenes. I have two arrays which i stored for my number and operator buttons. I am using a button function to switch between scenes and would like to remove the children for all the buttons inside that array however it only removes one button inside the array. This is the code i have so far:

My buttons:

```auto
var btn:Array = new Array();
for (var i = 0; i < 10; i++) {
    var myBtn:Btn = new Btn();
    myBtn.y = 15;
    myBtn.x = i * 100 + 15;
    myBtn.width = 48;
    myBtn.height = 48;
    myBtn.buttonMode=true;
    myBtn.mouseChildren=false;
    myBtn.num=Number(i);
    myBtn.caption.text=String(i);
    addChild(myBtn);
    btn.push(myBtn);
    myBtn.addEventListener(MouseEvent.CLICK,pressNumber);
}

```

Remove children:

```auto
stop();
changes.addEventListener(MouseEvent.CLICK,EnterFrame );
function EnterFrame(event:MouseEvent):void 
{
gotoAndStop(2, "Calculator");
while (myBtn.numChildren > 0) 
{
 myBtn.removeChildAt(myBtn.numChildren-1);
}
opBtn.visible = false;
clearAll.visible=false;
pm.visible=false;
goBack.visible=false;
dot.visible=false;
equals.visible=false;
}

```
