# Problem with removechild

**URL:** <https://forum.kirupa.com/t/problem-with-removechild/319345>\
**Category:** flash\
**Created:** [February 17, 2011, 2:14am UTC](https://forum.kirupa.com/t/problem-with-removechild/319345 "2011-02-17T02:14:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lio89](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@lio89](https://forum.kirupa.com/u/lio89)\
**Post date:** [February 17, 2011, 2:14am UTC](https://forum.kirupa.com/t/problem-with-removechild/319345/1 "2011-02-17T02:14:57Z")

</div>

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:

```auto
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
