ADOBE FLEX 3
Developer Guide
519
Calling ActionScript code from code in a container application
Creating a proxy to simplify calling ActionScript code from a container application
Important concepts and terms
The following reference list contains important terms used in this chapter:
ActiveX container: A container application (not a web browser) that includes an instance of the Flash Player
ActiveX control to display SWF content within the application.
Container application: The application within which Flash Player is running a SWF file, such as a web browser
and HTML page that includes Flash Player content.
Projector: A SWF file that has been converted into a standalone executable file including Flash Player as well as
the SWF files content. A projector can be created in Adobe Flash CS3 Professional or using the standalone Flash
Player. Projectors are commonly used to distribute SWF files by CD-ROM or in similar situations where download
size is not an issue and the SWF author wants to be certain the user will be able to run the SWF file, regardless of
whether Flash Player is installed on the user’s computer.
Proxy: A go-between application or code that calls code in one application (the external application”) on behalf
of another application (the “calling application”), and returns values to the calling application. A proxy can be used
for various reasons, including:
To simplify the process of making external function calls by converting native function calls in the calling
application into the format understood by the external application
To work around security or other restrictions that prevent the caller from communicating directly with the
external application
Serialize: To convert objects or data values into a format that can be used to pass the values in messages between
two programming systems, such as over the Internet or between two different applications running on a single
computer.
External API requirements and advantages
The external API is the portion of ActionScript that provides a mechanism for communication between ActionScript
and code running in anexternal application” that is acting as a container for Flash Player (commonly a web browser
or stand-alone projector application). In ActionScript 3.0, the functionality of the external API is provided by the
ExternalInterface class. In Flash Player versions prior to Flash Player 8, the
fscommand() action was used to carry
out communication with the container application. The ExternalInterface class is a replacement for
fscommand(),
and its use is recommended for all communication between JavaScript and ActionScript.
Note: If you need to use the old
fscommand() function—for example, to maintain compatibility with older applications
or to interact with a third-party SWF container application or the stand-alone Flash Player—it is still available as a
package-level function in the flash.system package.
The ExternalInterface class is a subsystem that lets you easily communicate from ActionScript and Flash Player to
JavaScript in an HTML page, or to any desktop application that includes an instance of Flash Player.

Get ADOBE® FLEX® 3: PROGRAMMING ACTIONSCRIPT™ 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.