ArgumentError: Error #2025

Hi,

I am in the middle of creating a shooting game. I just have a plane which is controlled by arrow keys and bullets are fired when spacebar is pressed. Enemies come and are removed when bullet hits it. Everything else is working fine but when the bullets hit the enemy I am getting this error

“ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at MethodInfo-17()”

Rest is working fine I think. Here are the two function where I am removing bullets and enemies

bullet function

stage.addEventListener(KeyboardEvent.KEY_DOWN, fireBullet);
function fireBullet(event:KeyboardEvent):void{
if(event.keyCode==32)
{//trace(score);score++;
var bullets:Sprite = new bullet();
bullets.x=myPlane.x+myPlane.width/2;
bullets.y=myPlane.y+8;
bulletTrack.addChild(bullets);
bulletTrack.addEventListener(Event.ENTER_FRAME,moveBullet);
}
function moveBullet(event:Event):void {

if(bullets.x>560||time==0){
bulletTrack.removeEventListener(Event.ENTER_FRAME,moveBullet);
bulletTrack.removeChild(bullets);

}
bullets.x=bullets.x+7;

}
}

enemy function

function onstart(e:Event){

var em:Sprite = new enemy();
em.x=550;
em.y= Math.random()*550;

addChild(em);
addEventListener(Event.ENTER_FRAME,moveEN);
function moveEN(event:Event):void{

if(em.x<0||time==0){
removeEventListener(Event.ENTER_FRAME,moveEN);
removeChild(em);

}
em.x=em.x-3;
for (var i:int = 0; i<bulletTrack.numChildren; i++) {
if(bulletTrack.getChildAt(i).hitTestObject(em)){
trace(“we got hit”);
trace(bulletTrack.numChildren);
score=score+100;
bulletTrack.removeChild(bulletTrack.getChildAt(i));
removeEventListener(Event.ENTER_FRAME,moveEN);
removeChild(em);
}
/

}
}
}

Here is the full code(just in case)

stop();
var myPlane:plane = new plane();
stage.addChild(myPlane);
myPlane.x = myPlane.width/2+30;
myPlane.y = myPlane.height/2+30;

var bulletTrack:Sprite = new Sprite();
addChild(bulletTrack);
var speed:Number = 1;

//the scorecount of the game
var score:int = 0;

var time:int = 10;

var tm:Timer = new Timer(1500);

tm.addEventListener(TimerEvent.TIMER, onstart);
tm.start();
function onstart(e:Event){

var em:Sprite = new enemy();
em.x=550;
em.y= Math.random()*550;

addChild(em);
addEventListener(Event.ENTER_FRAME,moveEN);
function moveEN(event:Event):void{

if(em.x<0||time==0){
removeEventListener(Event.ENTER_FRAME,moveEN);
removeChild(em);
//trace(“removed”);trace(stage.height);
}
em.x=em.x-3;
for (var i:int = 0; i<bulletTrack.numChildren; i++) {
if(bulletTrack.getChildAt(i).hitTestObject(em)){
trace(“we got hit”);
trace(bulletTrack.numChildren);
score=score+100;
//remove bullet and listerners
//bulletTrack.getChildAt(i).removeEventListener(Event.ENTER_FRAME,moveBullet);
bulletTrack.removeChild(bulletTrack.getChildAt(i));
removeEventListener(Event.ENTER_FRAME,moveEN);
removeChild(em);
}
//trace(bulletTrack.numChildren);

}
}
}

stage.addEventListener(Event.ENTER_FRAME, updatestats);

//////////////////
var timeTimer:Timer = new Timer(1000, 10);
timeTimer.start();
timeTimer.addEventListener(TimerEvent.TIMER, timeFunction);
function timeFunction(event:TimerEvent):void{
time = 10-timeTimer.currentCount;
}

timeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, endGame);
function endGame(event:TimerEvent):void {
trace(“time ended”);
stage.removeEventListener(Event.ENTER_FRAME, updatestats);
tm.removeEventListener(TimerEvent.TIMER, onstart);
stage.removeChild(myPlane);
gotoAndPlay(“win”);
//removeEventListener(Event.ENTER_FRAME,moveBullet);
}
///////////////////
stage.addEventListener(KeyboardEvent.KEY_DOWN, movePlane);
function movePlane(kevent:KeyboardEvent):void{
stage.addEventListener(Event.ENTER_FRAME, contFly);
function contFly(fevent:Event):void{
switch(kevent.keyCode){
case 37:
if(myPlane.x > 0+myPlane.width/2){
if(speed<5){
myPlane.x=myPlane.x-speed;
speed++;
}
myPlane.x=myPlane.x-speed;
}
break;
case 39:
if(myPlane.x < stage.stageWidth-myPlane.width/2){
if(speed<5){
myPlane.x=myPlane.x+speed;
speed++;
//trace(“x”);
}
myPlane.x=myPlane.x+speed;
}
break;
case 38:
if(myPlane.y > 0+myPlane.height/2){
if(speed<5){
myPlane.y=myPlane.y-speed;
speed++;
}
myPlane.y=myPlane.y-speed;
}
break;
case 40:
if(myPlane.y < stage.stageHeight-myPlane.height/2){
if(speed<5){
myPlane.y=myPlane.y+speed;
speed++;
}
myPlane.y=myPlane.y+speed;
}
break;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP, stopFly);
function stopFly(event:KeyboardEvent):void{
if(event.keyCode==37 || event.keyCode==38 || event.keyCode==39 || event.keyCode==40){
stage.removeEventListener(Event.ENTER_FRAME, contFly);
speed=1;
//trace(“stop”);
}
}

}
/////////////////////////////
stage.addEventListener(KeyboardEvent.KEY_DOWN, fireBullet);
function fireBullet(event:KeyboardEvent):void{
if(event.keyCode==32)
{//trace(score);score++;
var bullets:Sprite = new bullet();
bullets.x=myPlane.x+myPlane.width/2;
bullets.y=myPlane.y+8;
bulletTrack.addChild(bullets);
bulletTrack.addEventListener(Event.ENTER_FRAME,moveBullet);
}
function moveBullet(event:Event):void {
//if(bullets==null){trace(“no bullets”);}
//else{

if(bullets.x>560||time==0){
bulletTrack.removeEventListener(Event.ENTER_FRAME,moveBullet);
bulletTrack.removeChild(bullets);
//trace(“removed”);//trace(stage.height);
}
bullets.x=bullets.x+7;
// }

}
}
//////
/*function moveBullet(event:Event):void {
//if(bullets==null){trace(“no bullets”);}
//else{
if(bullets.x>560||time==0||bullets==null){
bulletTrack.removeEventListener(Event.ENTER_FRAME,moveBullet);
bulletTrack.removeChild(bullets);
//trace(“removed”);trace(stage.height);
}
bullets.x=bullets.x+7;
// }

}*/
////////////////////////////

function updatestats(event:Event):void{

stats.text = " Time: “+time+” Score: "+score;
}

I have spent 6 hours over the internet trying to figure out the problem. Please help me out.

Thanks