the problem is that for some reason my if statement doesn’t work
if( key.isDown( Keyboard.UP ) )
{
ship.thrust-=.02;
ship.gravity=-.050;
trace("up");
if(shipLanded=true)
{
removeChildFunc();
}
}
once the up key is pressed the button is to be removed IF shipLanded is true. so it should just bypass removeChildFunc.
after the above code i have
ship.moveShip();
ship.rotateShip();
moveRocks();
land();
[U]** trace("shipLanded= " + shipLanded );**[/U]
healthBar.subtractHealth(ship.damageAmt);
checkDeath();
ship.damageAmt=0;
then way down at the bottom i have my removeChildFunc()
public function removeChildFunc():void
{
trace("removing child");
trace(asBaseScreenButton.parent);
removeChild(asBaseScreenButton);
}
and here’s my output
shipLanded= true
shipLanded= true
shipLanded= true
up
removing child
[object PlayScreen]
shipLanded= false
up
removing child
null
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at PlayScreen/removeChildFunc()[C:\Documents and Settings\rob\Desktop\AS3\Projects\AsteroidSupply\Classes\PlayScreen.as:457]
at PlayScreen/upDate()[C:\Documents and Settings\rob\Desktop\AS3\Projects\AsteroidSupply\Classes\PlayScreen.as:162]
that shipLanded =false should preclude the removing child and the null and the error???