The ActionScript 3.0 Language and Components Reference supports several Adobe products, including Flex, Flash Player, and AIR. 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). Flash 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:
Instructions for running MXML examples
You can paste MXML examples into an MXML application to test them. Note that most MXML examples are complete applications so you typically create a new MXML file to run the example. You can also paste a portion of an MXML example into an existing MXML application file.
Instructions for running ActionScript examples
You can paste ActionScript examples that do not use a class structure into the mx:Script
tag of your MXML application. The simplest way to test the examples that use a class structure is to paste them into an ActionScript Project in Flash Builder as follows:
- Select the File > New > ActionScript Project menu option.
- For the Project Name, provide the name of the primary class (for example: ContextMenuExample).
- Flash Builder creates an ActionScript file based on the ActionScript Project template. Erase any default template content in the file.
- Paste the entire example, including package and import statements into the ActionScript file.
- 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.
Fri Mar 19 2010, 03:05 AM -07:00