Selection.getCaretIndex()
Availability
Flash Player 5.
Usage
Selection.getCaretIndex() : Number
Parameters
None.
Returns
An integer.
Description
Method; returns the index of the blinking insertion point (caret) position. If there is no blinking
insertion point displayed, the method returns -1. Selection span indexes are zero-based (for
example, the first position is 0, the second position is 1, and so on).
Example
The following example creates and sets the properties of a text field at runtime. The
getCaretIndex()
text field.
this.createTextField("pos_txt", this.getNextHighestDepth(), 50, 20, 100, 22);
this.createTextField("content_txt", this.getNextHighestDepth(), 50, 50, 400,
300);
content_txt.border = true;
content_txt.type = "input";
content_txt.wordWrap = true;
content_txt.multiline = true;
content_txt.onChanged = getCaretPos;
var keyListener:Object = new Object();
keyListener.onKeyUp = getCaretPos;
Key.addListener(keyListener);
var mouseListener:Object = new Object();
mouseListener.onMouseUp = getCaretPos;
Mouse.addListener(mouseListener);
function getCaretPos() {
pos_txt.text = Selection.getCaretIndex();
}
An example can also be found in the Strings.fla file in the HelpExamples Folder. Typical paths to
this folder are:
•
Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\
•
Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/
method is used to return the index of the caret and display its value in another
Selection.getCaretIndex()
717
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers