Ok folks, a number of tutorials have been written about creating a Tower Defense ( TD ) style game using Flash. The problem I ran into was that none of them seemed to be using Actionscript 3, or they were helpful but just not what I was looking for. So, I am hereby writing one as I work on mine.
A little background first… I have been doing web dev in PHP/Mysql for about 4 years now. That’s my spade, my ace, my trump card. That’s where my experience lies. I have been working with AS3 for about 6 months now, so if anyone notices I’m completely screwing things up, holla! If you know an easier, better way to code something, please let me know because at this point, I’m a sponge for knowledge. As such, after these tutorials are posted, I will be going back and revising them. This is all a work in progress, and hopefully the people that actually learn something will far outweigh those I completely confuse to the point of formatting.
Alright, enough of that… lets do it.
This is an exercise both in AS3 AND Object Oriented Programming. If you’re brand new to OOP, there are a number of good beginner tutorials, but I believe what I’ll be doing for this, if you’re into learning and reading and researching, it shouldn’t be too bad.
Go!
Alright, so I always pretty much start out every project the same. I’ll create a .fla file, and an actionscript .as file. I’ll stay generic here and create a td.fla as my main flash file. Original. Yup.
I’ll create a number of blank layers, you can see in the screenshot how I’ve got them set up. The top layer I’ll call “labels” so that from actionscript I can specifically jump to these frames during different stages of the game, “loading” , “playing” , and a “game over” frame. I have them 5 frames apart just to space things out, in the main document, it doesn’t really matter how many frames you use because we’re not going to be using much of that timeline for anything at this point.
So on the “labels” layer, I created blank keyframes on frame 5, 10, and 15. Then I clicked back to frame 1, and in the bottom left, Properties area I made the frame label “load_game”. For frame 5, “play_game”, and frame 10, “game_over”.
![]()
If you’ve ever seen tutorials and wondered how they got their frames so wide ( I did ) , here’s a quick screenshot. Just to the right of the timeline is a box you can click and change the frame width.

Some folks might go hardcore against using the timeline at all. That’s cool. I try to make things easier on myself, and if it takes 6 lines of code to make a text format and a text field, or just a couple of clicks to visually place a box where I want it.. that’s what I’m going to do.
On to the Document Class. We’re going to specify the main AS file we’ll be using.

You can see in the picture that I’ve changed the Frame Rate from 12 to 30 frames per second. I also changed the size of the document to 800px x 600px, and set the Document Class to “td.Main”. This means that my directory structure will look exactly like this:
/.. Root
|
– td.fla
|
– ” td ” directory
|
– Main.as
I’ll be putting the majority of my files in that “td” directory. We’ll see how that works as we move on to the actionscript.
Pages: 1 2
Tags: Actionscript 3, Game Development, Tutorials
Leave a reply
You must be logged in to post a comment.