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:
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:
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;
}