Creating a Project

  1. In the ActionScript2 Perspective, you can create a project with File→New→New ActionScript Project.
  1. The first screen of the Wizard should be straight-forward. You must provide a name for your project, you can follow the tradition and enter ‘HelloWorld’ or choose your own name. Here you can also choose the SWF version of your project, for now leave it set to 8.
  1. The second screen of the Wizard has you configure your classpath. The “src” folder, where you will add your ActionScript files, should already be shown. You will want to click the “Link Logger Classes” button. This will add a folder to your project, which is linked to ActionScript code which implements a variety of loggers. These two folders are your classpath, i.e. the place where the compiler (and parts of ASDT) will look for ActionScript classes.
  1. Click Finish to create the project.

Adding the "main" ActionScript class

The MTASC compiler differs from the Macromedia compiler, in that MTASC requires one ActionScript class to have a ‘main’ method, where execution begins. The concept will be familiar to Java and C programmers. Generally you can start development by creating this “main” class.

To add the “main” class, right click the “src” folder, and choose New→ActionScript class. You must enter a name for this class, the Package is optional. We will start with a simple class called “Hello” Enter “Hello” in the “Name” field, then tick the box that says ‘public static main()’ and click Finish. This will generate a new ActionScript file with the main method stub ready for us.

Because we are generating a ‘main’ class, ASDT now shows the ‘Build Item’ dialog where you can configure how the swf is built. Its quite an intimidating dialog at first sight, but most options are quite simple. You can read the Build Item Dialog page for a more detailed description, but for now just click OK. Next you will see the main project builder page which should have one entry in the list which is for the item we just saw. phew. Click OK again.

Now you can see the code that has been generated, fill in the rest of the code as shown below :

class Hello {

        // entry point
        public static function main(mc) {
                // creates a 'tf' TextField size 800x600 at pos 0,0
                _root.createTextField("tf",0,0,0,800,600);
                // write some text into it
                _root.tf.text = "Zdravo!";
        }
}

And save it. When you save this file the builder runs automatically to create your swf.

Look in the project navigator on the left and expand the ‘bin’ section. In there you should see ‘Hello.swf’. Double-click this to launch the swf in a new page and you will see the greeting you entered in the code.

Now we can try to get some logging (aka trace) output.