Advancing levels

Once all enemies have been destroyed, the player must be able to play the next level, with more enemies moving faster.

For our convenience, we should manage level creation with a function, changing Main function removing the for loop and adding a new function called playLevel.

public function Main() {

This function is just a cut/paste of the for loop previously included in Main function, but this way we can call playLevel from elsewhere.

private function playLevel():void {
for (var i:uint=1; i<level+3; i++) {

And in this specific case, we are calling it from onEnterFrm function ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.