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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

How to Use ActionScript Examples<br />

Running a practical example inFlash Builder<br />

Practical examples are normally delivered as ZIP archive files. To run a practical example using Flash Builder:<br />

1 Unzip the archive file into a folder of your choice. Give the folder a descriptive name (such as<br />

ContextM<strong>en</strong>uExample).<br />

2 In Flash Builder select File > New Flex Project. In the Project Location section, click Browse and select the folder<br />

containing the example files. In the Project Name field <strong>en</strong>ter the folder name (such as ContextM<strong>en</strong>uExample). Use<br />

the default values for other fields (or change them according to your specific <strong>en</strong>vironm<strong>en</strong>t). Click Next to continue.<br />

3 In the Output panel click Next to accept the default value.<br />

4 In the Source Paths panel click the Browse button next to the Main Application File field. Select the main MXML<br />

example file from the example folder. Click Finish to create the project files.<br />

5 To run the example, select the Run > Run m<strong>en</strong>u option for the main MXML file (such as Run > Run<br />

ContextM<strong>en</strong>uExample).<br />

Running ActionScript 3.0 examples on mobile devices<br />

You can run the ActionScript 3.0 code examples on mobile devices that support Flash Player 10.1. However, typically<br />

you run a code example to learn how particular classes and methods work. In that case, run the example on a nonmobile<br />

device such as a desktop computer. On the desktop computer, you can use trace statem<strong>en</strong>ts and other<br />

debugging tools in Flash Professional or Flash Builder to increase your understanding of a code example.<br />

If you want to run the example on a mobile device, you can either copy the files to the device or to a web server. To<br />

copy files to the device and run the example in the browser, do the following:<br />

1 Create the SWF file by following the instructions in “Running ActionScript 3.0 examples in Flash Professional” on<br />

page 1087 or in “Running ActionScript 3.0 examples in Flash Builder” on page 1088. In Flash Professional, you<br />

create the SWF file wh<strong>en</strong> you select Control > Test Movie. In Flash Builder, you create the SWF file wh<strong>en</strong> you run,<br />

debug, or build your Flash Builder project.<br />

2 Copy the SWF file to a directory on the mobile device. Use software provided with the device to copy the file.<br />

3 In the address bar of browser on the mobile device, <strong>en</strong>ter the file:// URL for the SWF file. For example, <strong>en</strong>ter<br />

file:://applications/myExample.swf.<br />

To copy files to a web server and run the example in the device’s browser, do the following:<br />

1 Create a SWF file and an HTML file. First, follow the instructions in “Running ActionScript 3.0 examples in Flash<br />

Professional” on page 1087 or in “Running ActionScript 3.0 examples in Flash Builder” on page 1088. In Flash<br />

Professional, selecting Control > Test Movie creates only the SWF file. To create both files, first select both Flash<br />

and HTML on the Formats tab in the Publish Settings dialog. Th<strong>en</strong> select File > Publish to create both the HTML<br />

and SWF files. In Flash Builder, you create both the SWF file and HTML file wh<strong>en</strong> you run, debug, or build your<br />

Flash Builder project.<br />

2 Copy the SWF file and HTML file to a directory on the web server.<br />

3 In the address bar of browser on the mobile device, <strong>en</strong>ter the HTTP address for the HTML file. For example, <strong>en</strong>ter<br />

http://www.myWebServer/examples/myExample.html.<br />

Before running an example on a mobile device, consider each of the following issues.<br />

Last updated 6/6/2012<br />

1089

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

Saved successfully!

Ooh no, something went wrong!