The Flash Document Object Model
19
You can embed individual JSAPI commands in ActionScript files by using the
MMExecute()
command, which is documented in the
Flash MX 2004 ActionScript Language Reference
. However,
the
MMExecute()
command has an effect only when it is used in the context of a custom user-
interface element, such as a component Property inspector, or a SWF panel within the authoring
environment. Even if called from ActionScript, JSAPI commands have no effect in Flash Player or
outside the authoring environment.
The JSAPI also contains a number of methods that let you implement extensibility using a
combination of JavaScript and custom C code. For more information, see
Chapter 4, “C-Level
Extensibility,” on page 369
.
Flash JavaScript objects contain properties and methods. Properties, each defined as a primitive
type such as Boolean, integer, array, float, or reference data types such as color, object, point, rect,
and String, are used to describe the object. Methods are used to perform a function on the object.
To access the properties or methods of an object, dot notation is used. Also, most objects have
getProperty()
and
setProperty()
methods, which get the value for a specified property or set
the value for a specified property. Most methods take parameters that are used to specify different
options for the method.
The JavaScript interpreter in Flash is the Mozilla SpiderMonkey engine, version 1.5, which is
available on the web at
http://www.mozilla.org/js/spidermonkey/
. SpiderMonkey is one of the
two reference implementations of the JavaScript language developed by Mozilla.org. It is the same
engine that is embedded in the Mozilla browser.
SpiderMonkey implements the entire core JavaScript language as defined in the ECMA-262
specification. It is fully compliant with ECMA-262 Edition 3. Only the browser-specific host
objects, which are not part of the ECMA-262 specification, are not supported.
All “Core JavaScript” sections of Netscape’s JavaScript documentation at
http://
devedge.netscape.com/central/javascript/
apply to the Flash JavaScript interpreter. All “Client-
Side JavaScript” sections do not apply because they only apply to browser environments.
SpiderMonkey is also used in Fireworks MX 2004, Dreamweaver MX 2004, Director MX 2004
and Flash Communication Server MX.
The Flash Document Object Model
The DOM for the Flash JavaScript API consists of a set of top-level functions (see
“Top-level
functions” on page 25
) and the top-level
flash object
. The
flash
object is guaranteed to be
available to a script because it always exists when the Flash authoring environment is open. When
referring to this object, you can use
flash
or
fl
. For example, to close all open files, you can use
either of the following statements:
flash.closeAll();
fl.closeAll();
Summary of Contents for FLASH MX 2004-FLASH JAVASCRIPT DICTIONARY
Page 1: ...Flash JavaScript Dictionary ...
Page 16: ...16 Contents ...
Page 40: ...40 Chapter 2 Top level functions ...
Page 368: ...368 Chapter 3 Objects ...