142
Objects
To add objects to the array, you must first select them in one of the following ways:
■
Manually select object(s) on the Stage.
■
Use one of the selection methods, such as
document.setSelectionRect()
,
document.setSelectionBounds()
,
document.mouseClick()
,
document.mouseDblClk()
, or
document.selectAll()
.
■
Manually select a frame or frames.
■
Use one of the methods of the
Timeline object
to select a frame or frames, such as
timeline.getSelectedFrames()
,
timeline.setSelectedFrames()
, or
timeline.selectAllFrames()
.
■
Specify a particular element in a particular frame. For example, the following code
specifies and selects an element:
fl.getDocumentDOM().selection =
fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0];
Example
The following example assigns all elements on Frame 11 to the current selection (remember
that index values are different from frame number values):
fl.getDocumentDOM().getTimeline().currentFrame = 10;
fl.getDocumentDOM().selection =
fl.getDocumentDOM().getTimeline().layers[0].frames[10].elements;
The following example creates a rectangle in the upper-left corner of the Stage and a text
string underneath the rectangle. Then it selects both objects using
document.setSelectionRect()
and adds them to the
document.selection
array. Finally,
it displays the contents of
document.selection
in the Output panel.
fl.getDocumentDOM().addNewRectangle({left:0, top:0, right:99, bottom:99},
0);
fl.getDocumentDOM().addNewText({left:-1, top:117.3, right:9.2,
bottom:134.6});
fl.getDocumentDOM().setTextString('Hello World');
fl.getDocumentDOM().setSelectionRect({left:-28, top:-22, right:156.0,
bottom:163});
var theSelectionArray = fl.getDocumentDOM().selection;
for(var i=0;i<theSelectionArray.length;i++){
fl.trace("fl.getDocumentDOM().selection["+i+"] = " +
theSelectionArray[i]);
}
Содержание FLASH 8-EXTENDING FLASH
Страница 1: ...Extending Flash...
Страница 38: ...38 Top Level Functions and Methods...
Страница 532: ...532 Objects...
Страница 554: ...554 C Level Extensibility...