ActionScript projects

Flash Builder lets you create ActionScript projects that use the Flash API (not the Flex framework). This leverages the Flash Builder workbench tools and the ActionScript editor, which means that you have a full-featured IDE for developing ActionScript applications.

ActionScript projects do not have a visual representation in Flash Builder; in other words, there is no Design mode for ActionScript applications. You view your ActionScript applications by compiling them in Flash Builder and then running them in Flash Player. You can use all the debugging tools.

When you create an ActionScript project or a stand-alone ActionScript file to contain functions, a class, or interface, the Flex development perspective is modified to support the ActionScript editor. The primary supporting views of the ActionScript editor are the Outline and Problems views.

Creating ActionScript projects

When you create an ActionScript project, the New ActionScript Project wizard guides you through the steps, prompting you for the type of project to create, the project's name, location, and other advanced options.

  1. Select File > New > ActionScript Project.

  2. Enter a Project name, and then specify the following:

    Project Location
    The default location is the current workspace. On Windows platforms, the default workspace location is C:\Documents and Settings\Flex Developer\Adobe Flash Builder\. On the Macintosh, the default workspace location is /Users/Flex Developer/Adobe Flash Builder/. You can choose a different project location by deselecting the Use Default Location option.

    Flex SDK Version
    Choose default or specific. You can also click the Configure SDKs link to add, edit, or remove SDKs on the main Preferences page.

  3. Click Next to set the following advanced options (otherwise, click Finish):

    Source Path
    Specifies the path to link external resources to your application. For example, if you have a folder of shared ActionScript classes, you can link to that folder by adding it to the source path.

    Library Path
    Specifies the path to link external resource libraries (SWC files). By default, the library path of new ActionScript projects contains the playerglobal.swc and utilities.swc files.

    Main Source Folder
    Specifies, by default, the root of your project. You can, however, choose a different folder within the project. You can browse the project folder structure and create a folder for the source if needed.

    Main Application File
    Specifies the name of the ActionScript file that is the main application file. By default, Flash Builder uses the project name as the main application filename. You can change this name.

    Output Folder
    Specifies the location of the compiled application files. By default, this is the bin folder, but you can change this.

    Output Folder URL
    Specifies the server location of the compiled application files. This is optional.

  4. When you finish entering the ActionScript project settings, click Finish.

Creating an ActionScript class

You can use a wizard in Flash Builder to quickly create ActionScript classes for your Flex and ActionScript projects. The wizard also provides an easy way to generate stubs for functions that must be implemented.

  1. Select File > New > ActionScript Class.

  2. Specify the basic properties of your new class in the dialog box, and then click Finish.

    After clicking Finish, Flash Builder saves the file in the specified package and opens it in the code editor.

    If you saved the file in the current project or in the source path of the current project, Flash Builder also displays the component in the Components view so that you can rapidly insert it in your applications. For more information, see Add components in MXML Design mode.

  3. Write the definition of your ActionScript class.

    For more information, see Simple Visual Components in ActionScript.

Creating an ActionScript interface

You can use a wizard in Flash Builder to quickly create ActionScript interfaces for your Flex and ActionScript projects. An interface is a collection of constants and methods that different classes can share.

  1. Select File > New > ActionScript Interface.

  2. Specify the basic properties of your new interface in the dialog box, and then click Finish.

  3. Add any constants or methods to your ActionScript interface that different classes share.

Generating Accessor Functions

Get and set accessor functions (getters and setters) let you keep class properties private to the class. They allow users of the class to access those properties as if they were accessing a class variable (rather than calling a class method).

Flash Builder can generate ActionScript get and set accessor functions for class variables. When you generate getters and setters, Flash Builder provides the following options:

  • Make the class variable private.

    Typically, class variables have private access.

  • Rename the class variable, suggesting a leading underscore for the variable name.

    By convention, private class variables have a leading underscore.

  • Rename the accessor functions.

  • Specify whether to generate both getter and setter accessor functions.

  • Specify the placement of the accessor function in any of the following locations:

    • Before the first method

    • After the last method

    • Before variable declarations

  • Preview the code that will be generated.

Generate get or set accessor functions

  1. With an ActionScript file open in the Source Editor, place the cursor on a class variable.

  2. Select Source > Generate Getter/Setter from either the Flash Builder menu or the context menu.

  3. In the Generate Getter/Setter dialog, specify details for the accessor functions and click OK.

    Note: If you want to view the code that will be generated, select Preview before clicking OK.