findText (TextSnapshot.findText method)

public findText(startIndex:Number, textToFind:String, caseSensitive:Boolean) : Number

Searches the specified TextSnapshot object and returns the position of the first occurrence of textToFind found at or after startIndex. If textToFind is not found, the method returns -1.

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

startIndex:Number - Specifies the starting index point in the TextSnapshot text at which to search for the specified text.

textToFind:String - The text to search for. Specify either a String literal (enclosed in quotation marks) or a variable.

caseSensitive:Boolean - Boolean value that specifies whether the found text must match the case of the string in textToFind (true); otherwise false.

Returns

Number - The zero-based index position of the first occurrence of the specified text, or -1 if no text matched.

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.

var my_mc:MovieClip = this;
var my_snap:TextSnapshot = my_mc.getTextSnapshot();
var index1:Number = my_snap.findText(0, "Snap", true);
var index2:Number = my_snap.findText(0, "snap", true);
var index3:Number = my_snap.findText(0, "snap", false);
trace(index1); // 4
trace(index2); // -1
trace(index3); // 4

See also

getText (TextSnapshot.getText method)