getSelectedText (TextSnapshot.getSelectedText method)

public getSelectedText([includeLineEndings:Boolean]) : String

Returns a string that contains all the characters specified by the corresponding TextSnapshot.setSelected() method. If no characters are specified (by the TextSnapshot.setSelected() method), an empty string is returned.

If you pass true for includeLineEndings, newline characters are inserted in the return string, and the return string might be longer than the input range. If includeLineEndings is false or omitted, the method returns the selected text without adding any characters.

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.

Parameters

includeLineEndings:Boolean [optional] - A Boolean value that specifies whether newline characters are inserted (true) or are not inserted (false) into the returned string. The default value is false.

Returns

String - A string that contains all the characters specified by the corresponding TextSnapshot.setSelected() method.

Example

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. Then 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.setSelected(0, 4, true); 
my_snap.setSelected(1, 2, false); 

var theText:String = my_snap.getSelectedText(false); 
trace(theText); // Text

When you test the SWF file, a colored rectangle surrounds the specified characters.

See also

getSelected (TextSnapshot.getSelected method), setSelected (TextSnapshot.setSelected method)