Do you remember the game Raiden? I remember pumping quarter after quarter into the Raiden machine at my local Papa Ginos. The shop no longer has that game within its doors, and was replaced by a trash barrel a few years back.
We can fix the problem though. We can just build the game ourselves!
For those of you unfamiliar with the game…here is a link to one of the many Flash tributes made to the original game. Check it out.
The very first thing you need is a ship. I don’t like having anything manually on my stage, so we are going to add the ship through code. In order to do this, you have to give the ship a class path.
You get this pop up by going into your library, right clicking whatever you want to be your ship, and then going to linkage.

If you get a pop up saying the class doesn’t exist, just hit OK. Flash will automatically build one for you.
Now are ready to start coding.
Adding the ship:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| package
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Stage;
public class Main extends Sprite
{
private var GameShip:Ship;
public function Main ( ) : void
{
GameShip = new Ship ( );
stage.addChild(GameShip);
GameShip.x = stage.stageWidth/2;
GameShip.y = stage.stageHeight - 50;
}
}
} |
Line 1: Starting the package
Lines 3-5: Importing the necessary classes for this code.
Line 7: Initiating my class. The Class has to be the same name as the Document Class. I am extending sprite so I can actually put stuff onto the stage. Also, I am extending sprite instead of extending movieclip because I am not actually going to put any code on the timeline and I am not going to be using any frame past frame one. Therefore, I am extending the lighter sprite.
Line 9: Making a private class variable of type Ship. The type should match whatever you made the class in the class path above.
Lines 11-17: Making a constructor for my class and adding the ship to the stage in the constructor so it is added automatically. I just set the X and Y values of my ship to be half the stage width and a little above the stage height. I use the stage.stageWidth and stage.stageHeight instead of static values because sometimes I might want to change the size of my Flash movie, and if I do that, I would have to go back into all my code and fix the static values.
Continue Reading »