
CHAPTER 4: User-Interface Tools Communicating with the Flash application 85
the bubbling phase. For example, the following click handler, registered with the parent dialog object,
responds only in the capture phase:
myDialog.addEventListener("click", handleAllItems, true);
This value is false by default, so if it is not supplied, the handler can respond only in the bubbling phase
when the object’s descendent is the target, or when the object is itself the target of the event (the
at-target phase).
To distinguish which of multiple registered handlers is being executed at any given time, the event object
provides the eventPhase
property, and the currentTarget property, which In the capture and bubbling
phases contains the ancestor of the
target object at which the currently executing handler was
registered.
Communicating with the Flash application
ScriptUI supports a Flash Player, which runs the Flash application within a window in an Adobe
application. The Flash application runs ActionScript, a different implementation of JavaScript from the
ExtendScript version of JavaScript that Adobe applications run.
To open a Flash Player, add a control of type flashplayer
to your ScriptUI window. A control object of this
type contains functions that allow your script to load SWF files and control movie playback. It also contains
functions that allow your Adobe application script to communicate with the ActionScript environment of
the Flash application. See “
FlashPlayer control functions” on page 145.
A limited set of data types can be passed between the two scripting environments:
Number
String
Boolean
Null
undefined
Object
Array
The ActionScript class and date objects are not supported as parameter values.
In the ActionScript script for your Flash application, you must prepare for two-way communication by
providing access to the External API. Do this by importing the
ExternalInterface class into your Flash
application:
import flash.external.ExternalInterface;
Calling ExtendScript functions from ActionScript
The ActionScript ExternalInterface class allows you to call an ExtendScript function that has been
defined in the
FlashPlayer element in the Adobe application script, and run it in the ActionScript
environment. You must define the method in your FlashPlayer
element with a matching function name.
For example, in order for the SWF code to call an ExtendScript function named
myExtendScriptFunction,
define a function with the name
myExtendScriptFunction as a method of your FlashPlayer control
object. There are no special requirements for function names, but the function must take and return only
data of the supported types.
Kommentare zu diesen Handbüchern