I'm trying to make a space shooter game, I've managed to get bullets firing from the ship. I want the bullets to be removed when they reach the top of the screen. Here is the code I have:
for each(var playerBullet:PlayerBullet in playerBullets)
{
playerBullet.move();
if(playerBullet.y<0)
{
stage.removeChild(playerBullet);
}
}
This brings up error:
Error #2025: The supplied DisplayObject must be a child of the caller
The playerBullet.move() code works perfectly fine but trying to remove the bullets brings up errors. Can anybody give me tips to fix this? Thanks in advance