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 />

Working with movie clips<br />

The RuntimeAssetsExplorer application loads any SWF file that is a subclass of RuntimeAsset and allows you to<br />

browse the available assets of that SWF file. The example illustrates the following:<br />

Loading an external SWF file using Loader.load()<br />

Dynamic creation of a library symbol exported for ActionScript<br />

ActionScript control of MovieClip playback<br />

Before beginning, note that each of the SWF files to run in Flash Player must be located in the same security sandbox.<br />

For more information, see “Security sandboxes” on page 1033.<br />

To get the application files for this sample, download the Flash Professional Samples. The RuntimeAssetsExplorer<br />

application files can be found in the folder Samples/RuntimeAssetsExplorer. The application consists of the following<br />

files:<br />

File Description<br />

RuntimeAssetsExample.mxml<br />

or<br />

RuntimeAssetsExample.fla<br />

Establishing a run-time library interface<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

In order for the explorer to properly interact with a SWF library, the structure of the run-time asset libraries must be<br />

formalized. We will accomplish this by creating an interface, which is similar to a class in that it’s a blueprint of<br />

methods that demarcate an expected structure, but unlike a class it includes no method bodies. The interface provides<br />

a way for both the run-time library and the explorer to communicate to one another. Each SWF of run-time assets that<br />

is loaded in our browser will implem<strong>en</strong>t this interface. For more information about interfaces and how they can be<br />

useful, see Interfaces in Learning ActionScript 3.0.<br />

The RuntimeLibrary interface will be very simple—we merely require a function that can provide the explorer with an<br />

array of classpaths for the symbols to be exported and available in the run-time library. To this <strong>en</strong>d, the interface has<br />

a single method: getAssets().<br />

Last updated 6/6/2012<br />

The user interface for the application for Flex (MXML)<br />

or Flash (FLA).<br />

RuntimeAssetsExample.as Docum<strong>en</strong>t class for the Flash (FLA) application.<br />

GeometricAssets.as An example class that implem<strong>en</strong>ts the RuntimeAsset<br />

interface.<br />

GeometricAssets.fla A FLA file linked to the GeometricAssets class (the<br />

docum<strong>en</strong>t class of the FLA) containing symbols that<br />

are exported for ActionScript.<br />

com/example/programmingas3/runtimeassetexplorer/RuntimeLibrary.as An interface that defines the required methods<br />

expected of all run-time asset SWF files that will be<br />

loaded into the explorer container.<br />

com/example/programmingas3/runtimeassetexplorer/AnimatingBox.as The class of the library symbol in the shape of a<br />

rotating box.<br />

com/example/programmingas3/runtimeassetexplorer/AnimatingStar.as The class of the library symbol in the shape of a<br />

rotating star.<br />

331

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

Saved successfully!

Ooh no, something went wrong!