ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > TextSnapshot > setSelectColor (TextSnapshot.setSelectColor method) | |||
public setSelectColor(color:Number) : Void
Specifies the color to use when highlighting characters that were selected with the TextSnapshot.setSelected() method. The color is always opaque; you can't specify a transparency value.
This method works correctly only with fonts that include character metric information; however, by default, Adobe Flash does not include this information for static text fields. Therefore, the method might return -1 instead of an index value. To ensure that an index value is returned, you can force the Flash authoring tool to include the character metric information for a font. To do this, add a dynamic text field that uses that font, select Character Options for that dynamic text field, and then specify that font outlines should be embedded for at least one character. (It doesn't matter which characters you specify, nor if they are the characters used in the static text fields.)
Availability: ActionScript 1.0; Flash Player 7 - The SWF file must be published for Flash Player 6 or later, and must be played in Flash Player 7 or later.
color:Number - The color used for the border placed around characters that have been selected by the corresponding TextSnapshot.setSelected() method, expressed in 0xRRGGBB format.
The following example illustrates how to use this method. To use this code, place a static text field that contains the text "TextSnapshot Example" on the Stage. In the library, include the font used by the static text field, and in Linkage options for the font, select Export for ActionScript. Add the following ActionScript to Frame 1 of the Timeline:
var my_snap:TextSnapshot = this.getTextSnapshot(); var count:Number = my_snap.getCount(); my_snap.setSelectColor(0xFF0000); my_snap.setSelected(0, 4, true); my_snap.setSelected(1, 2, false); var theText:String = my_snap.getSelectedText(false); // get the selected text trace(theText); // Text
When you test the SWF file, you see a colored rectangle surrounds the specified characters.
setSelected (TextSnapshot.setSelected method)
|
|
|
|