This long article documents the development process (from requirements definition to release) of a Flash game written in ActionScript2 using entirely OOP (Object Oriented Programming). The game is a standard space shoot'em-up with 3 enemy ships and the player firing lasers.

(continues from page 2)

In this third part of our development process we will need to check our lives left and deal with it accordingly.

CHECK LIVES

In your .fla, make two new frames and put the code that was on frame 1 onto frame 2.
Add a stop() action at the top of the code. Add stop() on frames 1 and 3.
On frame 1, add a title, some instructions and a button. On the button, add this code:

on(release){
_root.gotoAndStop(2);
}

On frame 3 add a dynamic textbox to display the results of the game and call the instance "result_txt" .
Add a restart button and put this code on it to take it back to frame 2:

on(release){
_root.gotoAndStop(2);
}

Go to our Game class code and add this method that will check how many lives left and deal with the consequences:

We have two choices here. We can just make a scrolling background inside our Flash API or make a Background class and put the machinery for scrolling inside that...
Well I decided to make a Background class and put all the code inside that.
Firstly make 4 mc's twice the width of your Stage and the same height as the stage. Mine turned out at 1400x400. I am going to use parallax with my background. The closest grounds will be moving faster than the grounds that are further back. I named my instances of these mc's sky, far, mid, and fore.
And here is the Background class:

All that is well and good but now we can't see our display for the score and lives. That is because our textboxes are at root level and the backgrounds are at depths 1-4, and cover them. So what we need to do is add the test dynamically, and put them at a higher depth.
Add this line in Game class where we have declared our variables:

var myformat:TextFormat;

This will allow us to format our text later. And in the "initGame" method add the dynamic text fields: