Adobe Extending Flash Professional CS5 User Manual
Page 159

137
EXTENDING FLASH PROFESSIONAL
Document object
Last updated 5/2/2011
•
Specify all the elements in a particular frame (see
). See the first example below.
•
Create an array of one or more elements and then assign that array to the
document.selection
array. See the third
example below.
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
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 fl.trace("fl.getDocumentDOM().selection["+i+"] = " + theSelectionArray[i]); } The following example is an advanced example. It shows how to loop through the layer array and elements array to myMovieClip in the first frame to the current selection:
locate instances of a particular symbol and select them. You could extend this example to include loops for multiple
frames or scenes. This example assigns all instances of the movie clip