Tutorial 1 - Getting started with Flash 9 Alpha and Actionscript 3
I will try to explain AS 3 in simple words (instead of using a lot of professional terms). If you already have some experience in AS then you should be able to follow AS 3 easily. If you are completely new to AS, you may need to put more hardwork on learning the codes. If you have experience in Java programming, you should find the new syntax familiar.
This tutorial aims at introducing breifly the structure and syntax of AS 3. I will tell you how to write a simple program and make it run.
Click here to download files for that tutorial
What should you prepare?
Of course you should first install Flash 9 Alpha. You should always refer to the LiveDocs for AS 3 language and syntax whenever you have problem in coding. If you want to, you may also read more on Objected Oriented Programming (OOP).
You may want to have a look at the following:
- AS 3 from Adobe Wiki
- AS 3 Overview from Adobe
- AS 3 sample files from Adobe
- AS 2 and AS 3 comparsion
You may want to have a look at the. You can also download some .
Let's get started - Hello World
1. Open Flash 9 Alpha and start a new Actionscript file. Name it helloWorld.as. Beware of all the file names or variable names. AS 3 is case sensitive.
2. Enter the following code:
| Line | Description |
| 1 | This indicate that the following is a package of codes/functions defining a class. Just remmeber to type it in the first line. |
| 3 | Import the class MovieClip into the program for later use. |
| 5 | Define the main class of this file: helloWorld. Note that the file name and class name must be the same. public means that the class can be called from outside (we will come back to that later). extends MovieClip means that our class will be built based on the class MovieClip. |
| 7-9 | Define the main function of that class. Note that this function name is same as the class name, i.e. helloWorld. This function will be executed for sure. Remmeber to add ( ) behind the function name. |
| 8 | Output something to the output window of the Flash IDE. If you do not know what trace() is, I suggest you read it up in LiveDocs. |
Basically the above code just output some words to the output window. Don't worry now if you cannot understand fully the codes or syntax. Just try to type the codes and you will know more later.
How to make it run?
Since this is only a .as file, you cannot just output a .swf and run it like a .fla. To run the code, associate it with a .fla and output that .fla.
1. Open a new .fla file. Name it tut_1.fla (just name it as you like). Save it in the same folder as helloWorld.as.
2. There is a new field in the Properties panel: Document class. Type in helloWorld.

This will make the current timeline an instance of our class helloWorld. In simple words, this associates our class with the fla, and by outputting the fla, the above codes will be executed.
3. Test the movie by Control -> Test Movie. Make sure that you are outputting it as AS 3 for Flash Player 9. You should be able to see something like this:

The swf is of course blank since we did not put anything in it. The world "Hello!" is traced in the output window.
This ends the first tutorial. Don't worry if you have problems in understanding the codes. The more you practise AS3, the more you will understand.
Back to the Tutorial index page