MACROMEDIA FLASH 8-EXTENDING FLASH Manual page 16

Extending flash
Table of Contents

Advertisement

Specifying the target of an action
Unless otherwise specified, methods affect the current focus or selection. For example, the
following script doubles the size of the current selection because no particular object is
specified:
fl.getDocumentDOM().scaleSelection(2, 2);
In some cases, you might want an action to specifically target the currently selected item in
the Flash document. To do this, use the array that the
contains (see
document.selection
selected item, as shown in the following example:
var accDescription = fl.getDocumentDOM().selection[0].description;
The following script doubles the size of the first element on the Stage that is stored in the
element array, instead of the current selection:
var element =
fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];
if (element) {
element.width = element.width*2;
element.height = element.height*2;
}
You can also do something such as loop through all the elements on the Stage and increase the
width and height by a specified amount, as shown in the following example:
var elementArray =
fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements;
for (var i=0; i < elementArray.length; i++) {
var offset = 10;
elementArray[i].width += offset;
elementArray[i].height += offset;
}
Summary of the DOM structure
The following list displays the DOM structure in outline format. Numbers at the beginning
of each line represent the level of an object. For example, an object preceded by "03" is a child
of next highest "02" object, which, in turn, is a child of the next highest "01" object.
In some cases, an object is available by specifying a property of its parent object. For example,
the
document.timelines
document.timelines
outline.
16
Introduction
). The first element in the array represents the currently
property contains an array of Timeline objects (see
and
Timeline
object). These properties are noted in the following
document.selection
property

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-EXTENDING FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents