Gramlich Design Flash Tutorial
How to make a basic flash overhead view video game using Actionscript 2.0

Part 1: Getting Started

1. Set your movie to 30 fps. This code is for actionscript 2.0. The first thing you need is a background image of some sort. You can either make it in flash or import an outside image. Whatever you decide to do, make sure you make the image into a movie clip, (f8) that way you can re-use the same movie clip over and over throughout your game and easily change an entire world just by simply editing 1 movie clip. So here is what my flash file looks like so far

Notice i gave the movie clip "lake" an instance name of water. This will be useful later when we make the character swim.

2. Next make a character looking forward, looking backward, and looking to the side, then turn the front view into a movie clip and put that movie clip into layer 3.

3. Double click the movie clip and start a new timeline. Bust the timeline into 4 parts. Give each section the frame labels of front, back,right, and left. Put a stop command in each section as well.

4. Now you must line all the images up in the correct spots on the main hero layer

5. Go back to the main timeline and click on the character. Open the actions panel and put int his code.

onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
this.gotoAndStop("front");
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("left");
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("right");
}
if (Key.isDown(Key.UP)) {
this.gotoAndStop("back");
}
}

Basically, all this code is doing is letting you communicate with the movie clip with the keyboard and telling it to go to a frame label depending on which key you are pressing

Now you can use the arrow keys to control which direcion the character is looking.

6. Now we will make the character walk. Put this code on the hero movie clip. The new code is in red

onClipEvent (load){
heropower = 0.95;
heroyspeed = 0;
heroxspeed = 0;
herofriction = 0.76;
}


onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
this.gotoAndStop("front");
heroyspeed += heropower;
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("left");
heroxspeed -= heropower;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("right");
heroxspeed += heropower;
}
if (Key.isDown(Key.UP)) {
this.gotoAndStop("back");
heroyspeed -= heropower;
}
heroxspeed *= herofriction;
heroyspeed *= herofriction;
_y += heroyspeed;
_x += heroxspeed;

}

You can control the speed of the character by changing the value of the heropower variable at the top of the script. The herofriction variable determines how long it takes for the character to reach top speed and how fast it takes for it come to a complete stop.

This concludes the first lesson! I hope it was helpful.