I have a game, where enemys spawn randomly, from this tutorial. It works fine but when the flash goes to another frame they keep coming :S
This is the code:
onEnterFrame = function () {
if (random(10) == 0) {
attachMovie("bullet","b"+i,getNextHighestDepth(),{_y:random(Stage.width), _x:Stage.height});
bullets[bullets.length] = i;
i++;
}
for (j=0; j<bullets.length; j++) {
n = bullets[j];
_root["b"+n]._x -= 20;
if (_root["b"+n].hitTest(_root.wall)) {
removeMovieClip(_root["b"+n]);
_root.touched ++;
bullets.splice(j,1);
}
}
};
}
How do I stop this? I know it has something to do with removeMovieClip(); or something like that but I'm not too sure.