The flash document object model, The document object – Adobe Extending Flash Professional CS5 User Manual
Page 31
9
EXTENDING FLASH PROFESSIONAL
Introduction
Last updated 5/2/2011
The Flash Document Object Model
The Flash Document Object Model (DOM) for the Flash JavaScript API consists of a set of top-level functions (see
“
Top-Level Functions and Methods
” on page 14) and two top-level objects—the FLfile object and the flash object (fl).
Each object is guaranteed to be available to a script because it always exists when the Flash authoring environment is
open. For more information, see
When referring to the flash object, you can use
flash
or
fl
. For example, to close all open FLA files, you can use either
of the following statements:
flash.closeAll();
fl.closeAll();
The flash object contains the following child objects:
The Document object
An important property of the top-level flash object is the
property. This property contains an array of
Document objects, each of which represents one of the FLA files currently open in the authoring environment. The
properties of each Document object represent most of the elements that a FLA file can contain. Therefore, a large
portion of the DOM is composed of child objects and properties of the Document object. For more information, see
To refer to the first open document, for example, use the statement
flash.documents[0]
or
fl.documents[0]
. The
first document is the first Flash document that was opened during the current session in the authoring environment.
When the first opened document is closed, the indexes of the other open documents are decremented.
To find a particular document’s index, use
flash.findDocumentIndex(
nameOfDocument
) or
fl.findDocumentIndex(
nameOfDocument
)
Object
How to access
actionsPanel object
Use
fl.actionsPanel
to access the actionsPanel object. This object corresponds to the Actions
panel in the Flash authoring environment.
compilerErrors object
Use
fl.compilerErrors
to access the compilerErrors object. This object corresponds to the
Compiler Errors panel in the Flash authoring environment.
componentsPanel object
Use
fl.componentsPanel
to access the componentsPanel object. This object corresponds to the
Components panel in the Flash authoring environment.
Document object
Use
fl.documents
to retrieve an array of all the open documents; use
fl.documents[index]
to
access a particular document; use
fl.getDocumentDOM()
to access the current document (the one
with focus).
drawingLayer object
Use
fl.drawingLayer
to access the drawingLayer object.
Math object
Use
fl.Math
to access the Math object.
outputPanel object
Use
fl.outputPanel
to access the outputPanel object. This object corresponds to the Output panel
in the Flash authoring environment.
presetPanel object
Use
fl.presetPanel
to access the presetPanel object. This object corresponds to the Motion Presets
panel (Window
> Motion Presets).
swfPanel object
Use
fl.swfPanels
to access an array of swfPanel objects. These objects correspond to Window SWF
panels.
Tools object
Use
fl.tools
to access an array of Tools objects.
XMLUI object
Use
fl.xmlui
to access an XML User Interface (XMLUI) object. The XMLUI object provides the ability
to get and set properties of an XMLUI dialog box.