ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
Using examples in the ActionScript 3.0 Language and Components Reference

The ActionScript 3.0 Language and Components Reference supports several Adobe products, including Flash CS4 and Flex 3. The content covers application programming interfaces (APIs) that are specific to ActionScript and that may be implemented differently depending on the authoring tool you are using. Therefore, to test and use the example code in the ActionScript 3.0 Language and Components Reference, you need to know the implementation for the authoring tool you are using. For example, the ActionScript 3.0 Language and Components Reference contains some examples that use a class structure (such as the flash.ui.ContextMenu class example) and other examples that do not (such as the flash.display.DisplayObjectContainer.mouseChildren property example). Flex Builder users can test the ContextMenu class example by pasting it directly into an ActionScript Project. (For MXML-based projects the class structure examples often need some additional Flex-specific code.) Flash authoring users need to paste that content into a class file to test it. The directions for each authoring tool are as follows:

Flash CS4 instructions

You can paste the examples that do not use a class structure into the Actions panel for the first layer of the first frame of the main timeline and test them using the Control > Test Movie menu option. For the examples that use a class structure, follow these steps:

1. Paste the class example code into a new AS file and give the file the same name as the primary class (for example: ContextMenuExample.as).
2. Create and save a new empty FLA file in the same directory as the AS file.
3. In the Properties tab of the Property inspector enter the class name of the primary class for the example in the Document class text box (for example: ContextMenuExample).
4. Save your changes to the FLA file.
5. Test the movie using the Control > Test Movie menu option.

Flex Builder instructions

You can paste examples that do not use a class structure into the `mx:Script` tag contents of your MXML application. The simplest way to test the examples that use a class structure is to paste them into an ActionScript Project as follows:

1. Select the File > New > ActionScript Project menu option.
2. For the Project Name, provide the name of the primary class (for example: ContextMenuExample).
3. Flex Builder creates an ActionScript file based on the ActionScript Project template. Erase any default template content in the file.
4. Paste the entire example, including package and import statements into the ActionScript file.
5. Test the example using either the Run or Debug command.

Note: If you test ActionScript examples that use the `addChild()` ActionScript method with Flash Player display objects (like a text field) within an MXML application, you will need to attach the code to a Flex UIComponent instead of adding the Flash Player display object.

© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:04 AM -07:00