Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Writing ActionScript 3.0 in Flash

Writing ActionScript 3.0 in Flash

The Flash Professional 9 ActionScript 3.0 Preview is the only development environment that allows you to create Flash documents (FLA files) that use ActionScript 3.0, although you can also compile SWF files from ActionScript (AS) files using Flex Builder 2.

The AS3 Preview enables you to build timeline-based ActionScript 3.0 documents and use other features available only in its authoring environment, such as shape and motion tweens, the flash.display.MorphShape class, the adobe.utils package, static text fields, scenes, and the Library.

The AS3 Preview contains several new features:

  • Document class: Flash 9 introduces the concept of a document class, a class definition associated with the main Timeline of your SWF file. When you initialize the main Timeline, the document class is constructed. You can set a document class in the Property inspector or in the ActionScript 3.0 Publish Settings dialog box by selecting File > Publish Settings > Flash tab > Settings button (see Figure 1).

    ActionScript 3.0 Settings dialog box

    Figure 1. ActionScript 3.0 Settings dialog box

  • Symbol-class linkage: You no longer need linkage identifiers in ActionScript 3.0. Instead, you can specify a class name for a Library symbol that you can instantiate directly and dynamically to create instances of that symbol (see Figure 2).

    Linkage Properties dialog box

    Figure 2. Linkage Properties dialog box

  • If the class definition does not exist on disk in the class path, then Flash creates one behind the scenes so it can still be instantiated (see Figure 3).

    ActionScript Class Warning dialog box

    Figure 3. ActionScript Class Warning dialog box

  • Errors and warnings: There are two additional options for ActionScript 3.0 errors and warnings, which you can toggle in the ActionScript 3.0 Preferences dialog box by selecting Edit > Preferences > ActionScript category > ActionScript 3.0 Settings button (see Figure 4).

    One option, Strict Mode, causes the compiler to be stricter about problems and treat them as errors instead of warnings. The other option, Warnings Mode, causes extra warnings to appear, many of which will help when you migrate ActionScript 2.0 code to ActionScript 3.0 code. You can toggle these warnings using the EnabledWarnings.xml file by setting the enabled attribute to false for the desired warning.

  • ActionScript 3.0 Preferences dialog box

    Figure 4. ActionScript 3.0 Preferences dialog box

The AS3 Preview makes it easy to create SWF files by positioning assets on the Stage at design time, rather than having to create or load assets on the fly at runtime in ActionScript-only environments.