03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Parameters<br />

color:Number - The color used for the border placed around characters that have been<br />

selected by the corresponding TextSnapshot.setSelected() method, expressed in<br />

0xRRGGBB format.<br />

Example<br />

The following example illustrates how to use this method. To use this code, place a static text<br />

field that contains the text "TextSnapshot Example" on the Stage. In the library, include the<br />

font used by the static text field, <strong>and</strong> in Linkage options for the font, select Export for<br />

<strong>ActionScript</strong>. Add the following <strong>ActionScript</strong> to Frame 1 of the Timeline:<br />

var my_snap:TextSnapshot = this.getTextSnapshot();<br />

var count:Number = my_snap.getCount();<br />

my_snap.setSelectColor(0xFF0000);<br />

my_snap.setSelected(0, 4, true);<br />

my_snap.setSelected(1, 2, false);<br />

var theText:String = my_snap.getSelectedText(false); // get the selected<br />

text<br />

trace(theText); // Text<br />

When you test the SWF file, you see a colored rectangle surrounds the specified characters.<br />

See also<br />

setSelected (TextSnapshot.setSelected method)<br />

setSelected (TextSnapshot.setSelected method)<br />

public setSelected(start:Number, end:Number, select:Boolean) : Void<br />

Specifies a range of characters in a TextSnapshot object to be selected or not. Characters that<br />

are selected are drawn with a colored rectangle behind them, matching the bounding box of<br />

the character. The color of the bounding box is defined by<br />

TextSnapshot.setSelectColor().<br />

To select or deselect all characters, pass a value of 0 for start <strong>and</strong><br />

TextSnapshot.getCount() (or any very large number) for end. To specify a single character,<br />

pass a value of start + 1 for end.<br />

Because characters are individually marked as selected, you can call this method multiple<br />

times to select multiple characters; that is, using this method does not deselect other<br />

characters that have been set by this method.<br />

1284 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!