I did some tests and found out that it's maybe not the enemies that are lagging over time. I still don't know what is causing this issue, but I've tried to to comment the content of the function that I use to spawn enemies, where I construct and put them in the array, and the game still lags, without any enemy spawning.
Assuming the movie clips are being properly removed from the stage, my guess is that the garbage collector isn't running because you haven't actually used enough memory for it to think that collection should be performed, however I'm not sure that this would be cause any lag over time.
I don't know how a garbage collector works, but I did this:
stage.removeChild(enemies[0]);
enemies.shift();
System.gc();
The game still ran but the lag over time problem was still there.
Are these enemies animated ? Removing a enemy from the stage, doesn't stop the movieclip from animating. So if you have enemies that are animated via tweens, they are likely still doing so if you haven't stopped the animation. That would explain the lagging over time.
Do the enemies have any event listeners attached to them ? That might be a reason why they are not being garbage collected.
But it's easy enough to test my theory if you have animated enemies, by just stopping the animation when you remove. We are theorizing at this point that they are not being removed. (good theory)
For now my enemies just have two frames, each with a stop(); on the frame. I just use this to change their image when they are damaged. About if they have a listener, I don't think so, at least not that I know. I only declared these three for now:
stage.addEventListener(Event.ENTER_FRAME, mainLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN, moveB);
stage.addEventListener(KeyboardEvent.KEY_DOWN, changeLaneCount);
Anyway, in my code I have commented all the lines that I thought that could possibly make my game lag over time, no sucess. I'm kinda stuck now. Do you have some tips on how to solve this kind of problem?