the button is added in Land():
function land():void
{
if(ship.xVel==0 && ship.yVel==0 && rocks.x>50 && rocks.x<350 && rocks.y>311 && rocks.y<319)
{
shipLanded=true;
//var asBaseScreenButton:ASBaseDockButn=new ASBaseDockButn("asBaseScreen");
asBaseScreenButton.x=35;
asBaseScreenButton.y=-50;
asBaseScreenButton.scaleX=.8;
asBaseScreenButton.scaleY=.8;
[U]** rocks.asBaseActual.addChild(asBaseScreenButton);**[/U]
DocksArray.push(asBaseScreenButton);
//trace (asBaseScreenButton.parent);
asBaseScreenButton.addEventListener(MouseEvent.CLICK,toAsBaseScreen);
}
else
{
shipLanded=false;
}
the player can either click the button and change screens or apply thrust and leave. If he hits thrust i want to remove the child with removeChildFunc()
if( key.isDown( Keyboard.LEFT ) )
{
ship.rVel-=2;
ship.gravity=-.050;
}
if( key.isDown( Keyboard.RIGHT ) )
{
ship.rVel+=2;
ship.gravity=-.050;
}
if( key.isDown( Keyboard.UP ) )
{
ship.thrust-=.02;
ship.gravity=-.050;
if(shipLanded==true)
{
[U]** removeChildFunc();**[/U]
}
}
on keyboard up removeChildFunc() is called which looks like:
public function removeChildFunc():void
{
trace("removing child");
trace(DocksArray[0]);
**[U]removeChildAt(DocksArray[0]);[/U]**
}
it traces removing child and the name of the child at DocksArray[0] but does not remove the child at DocksArray[0] or throw an error.
What am I doing wrong?