ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > TextSnapshot > getText (TextSnapshot.getText method) | |||
Returns a string that contains all the characters specified by the start and end parameters. If no characters are specified, the method returns an empty string.
To return all characters, pass a value of 0 for start, and TextSnapshot.getCount() (or any very large number) for end. To return a single character, pass a value of start +1 for end.
If you pass true for includeLineEndings, newline characters are inserted in the return string where deemed appropriate, 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.
start:Number - An integer that indicates the position of the first character to be included in the returned string. Valid values for start are 0 through TextSnapshot.getCount() - 1. If start is a negative value, 0 is used.
end:Number - An integer that is 1 + the index of the last character to be examined in the TextSnapshot object. Valid values for end are 0 through TextSnapshot.getCount(). The character indexed by the end parameter is not included in the extracted string. If you omit this parameter, TextSnapshot.getCount() is used. If the value of end is less than or equal to the value of start, start + 1 is used.
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.
String - A string that contains the characters in the specified range, or an empty string if no characters are found in the specified range.
The following example illustrates how you can return the number of characters in a specified TextSnapshot object. To use this code, place a static text field that contains the text "TextSnapshot Example" on the Stage.
var my_mc:MovieClip = this; var my_snap:TextSnapshot = my_mc.getTextSnapshot(); var count:Number = my_snap.getCount(); var theText:String = my_snap.getText(0, count, false); trace(count); // 20 trace(theText); // TextSnapshot Example
getCount (TextSnapshot.getCount method), getSelectedText (TextSnapshot.getSelectedText method)
|
|
|
|