Saludos
Hello
I got an easy problem, when doing a car’s game. I cannot remove a Child.
The error says the property is undefined.
This is the piece of code:
function crearID():void {
var rivaleses:rivales=new rivales();
var espacioalaizquierda:int= 95 + rivaleses.width/2
var espacioaladerecha:int= stage.stageWidth - 95 - rivaleses.width/2
var resta = espacioaladerecha - espacioalaizquierda;
var num = espacioalaizquierda + Math.round(Math.random()*resta);
rivaleses.y=10;
rivaleses.x= num;
miniauto.addEventListener(Event.ENTER_FRAME,avanzaMini);
addChild(rivaleses);
}
function dropEnemy(e:Event):void {
var caer:rivales=rivales(e.target);
caer.y+=10;
}
function avanzaMini(e:Event):void {
if(miniauto.hitTestObject(bandera.bandera_llegada)) {
miniauto.removeEventListener(Event.ENTER_FRAME,avanzaMini);
clearInterval(crearIDenemigo);
**removeChild(rivaleses);**
}else{
miniauto.y-=5;
}
}
The troublesome line is removeChild(rivaleses).
I need to erase that child when something happen in the gameplay
ah, function crearID comes from a setInterval
Lot of thank you, sorry about my weak english
Lionel