Anda di halaman 1dari 8

Basic AS3 tutorial

Basic AS3 Tutorial

Basic AS3 tutorial

First of all, it is explained how to prepare Eclipse in case of creating a project with Eclipse for
the first time. After that you will create your project and therein a class . At last, it is shown
how to run your new project .

Preparing the workbench

Before creating your first AS3 project the Adobe Flash Debug Player should definitely be
installed. It is important to install the Debug Player - not only the standard version - as you do
not get any "trace"- output otherwise. In addition, the Debug Player should also be installed in
the Internet Explorer - in case of working on windows - as some FDT tools refer to that plugin
when using windows. Among other things, the Debug Player is delivered with the FlexSDK that
ships with FDT.

Creating your first project

In order to set up a new project, please use the wizard that provides the appropriate support.
There are several ways to activate the wizard. In the following example the Flash Explorer is
being used. Right click with your mouse in your Flash Explorer window and choose "New->New
Flash Project".

When the wizard opens for a new project to be created you have to enter the project's name
and select the language version. In this example we name the project "Test" and choose Action
Script 3" and "Flex_3_SDK_0" as language version.

Basic AS3 Tutorial

Please press "Next" to continue with the following step.

Within the second step you create the source folder for your project. FDT has already created
several SWCs as Core Libraries . These include all basic classes necessary for the Flex
development, whereas the "playerglobal.swc" contains the definitions for "object", "class", etc.
If only the basic classes and not the Flex components are needed, the other SWCs can be
deleted later on.

Basic AS3 Tutorial

Click on "Finish" and the project is being created.

Create your first class

In order to create a first class the context menu of the Flash Explorer could be used. Using the
global buttons of Eclipse, however, is a little bit faster. First of all, select the source folder
"src" and click the button.

A dialog window appears helping you to create a new class. Name your class "Test1".
Additionally, define the superclass. Therefor click the "Browse..." button right of the input box
for "Superclass". Enter "sprite" in the appearing window and click "OK".

Basic AS3 Tutorial

Click on "Finish" and the new class is being created. An editor opens automatically and the
class appearsn in the Flash Explorer.

Basic AS3 Tutorial

The class already contains a comment. If and in which form it appears can be defined in the
preferences (" Customize your code Style "). Here the exact formatting, as for example the
whitespace to be generated or parentheses to be used, can as well be determined.

Run your first class

Now, please enlarge your class by another line so that you get to see results when executing.

package {
import flash.display.Sprite;
* @author ad
public class Test1 extends Sprite {
public function Test1() {
trace("Hello FDT!");

FDT offers several possibilities to compile ActionScript (read more under " Running and
building your programs "). The preferred method for AS3 is being provided by the FlexSDK. FDT
uses the compiler MXMLC and COMPC out of the FlexSDK as well as FCSH if that is installed.
In order to let the program run with its standard settings and receive "trace"-output, please
select the main class in the Flash Explorer and choose the "Debug AS...->FDT AS3 Application".

Basic AS3 Tutorial

A SWF is being generated in the project, a viewer being started and the "trace"-output is shown
in the Eclipse console. In case of no "trace"-output being shown, the Debug Player has
probably not been installed correctly.