13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

How to Use ActionScript Examples<br />

WordSearch (“Mouse input example: WordSearch” on page 576)<br />

Practical examples are also found with many of the Quick Start articles in the Flash Developer C<strong>en</strong>ter and Flex<br />

Developer C<strong>en</strong>ter.<br />

Running ActionScript 3.0 examples in Flash Professional<br />

Use one of the following procedures (dep<strong>en</strong>ding on example type) to run an example using Flash Professional.<br />

Running a code snippet example in Flash Professional<br />

To run a code snippet example in Flash Professional:<br />

1 Select File > New.<br />

2 In the New Docum<strong>en</strong>t dialog box, select Flash Docum<strong>en</strong>t, and click OK.<br />

A new Flash window is displayed.<br />

3 Click on the first frame of the first layer in the Timeline panel.<br />

4 In the Actions panel, type or paste the code snippet example.<br />

5 Select File > Save. Give the file a name and click OK.<br />

6 To test the example, select Control > Test Movie.<br />

Running a class-based example in Flash Professional<br />

To run a class-based example in Flash Professional:<br />

1 Select File > New.<br />

2 In the New Docum<strong>en</strong>t dialog box, select ActionScript File, and click OK. A new editor window is displayed.<br />

3 Copy the class-based example code and paste it into the editor window.<br />

If the class is the main docum<strong>en</strong>t class for the program, it must ext<strong>en</strong>d the MovieClip class:<br />

import flash.display.MovieClip;<br />

public class Example1 ext<strong>en</strong>ds MovieClip{<br />

//...<br />

}<br />

Also make sure that all the classes refer<strong>en</strong>ced in the example are declared using import statem<strong>en</strong>ts.<br />

4 Select File > Save. Give the file the same name as the class in the example (e.g. ContextM<strong>en</strong>uExample.as).<br />

Note: Some of the class-based examples, such as the flashx.textLayout.container.ContainerController class example,<br />

include multiple levels in the package declaration (package flashx.textLayout.container.examples {). For<br />

these examples, save the file in a sub folder that matches the package declaration<br />

(flashx/textLayout/container/examples), or remove the package name (so the ActionScript starts with package {<br />

only) and you can test the file from any location.<br />

5 Select File > New.<br />

6 In the New Docum<strong>en</strong>t dialog box, select Flash Docum<strong>en</strong>t (ActionScript 3.0), and click OK. A new Flash window is<br />

displayed.<br />

7 In the Properties panel, in the Docum<strong>en</strong>t Class field, <strong>en</strong>ter the name of the example class, which should match the<br />

name of the ActionScript source file you just saved (e.g. ContextM<strong>en</strong>uExample).<br />

Last updated 6/6/2012<br />

1087

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!