Document.settextstring() – Adobe Extending Flash Professional CS5 User Manual
Page 179
157
EXTENDING FLASH PROFESSIONAL
Document object
Last updated 5/2/2011
endIndex
An integer that specifies the end position of the selection up to, but not including, endIndex. The first
character position is 0 (zero).
Returns
A Boolean value:
true
if the method can successfully set the text selection;
false
otherwise.
Description
Method; sets the text selection of the currently selected text field to the values specified by the startIndex and endIndex
values. Text editing is activated, if it isn’t already.
Example
The following example selects the text from the 6th character through the 25th character:
fl.document.setTextSelection(5, 25);
document.setTextString()
Availability
Flash MX 2004.
Usage
document.setTextString(text [, startIndex [, endIndex]])
Parameters
text
A string of the characters to insert in the text field.
startIndex
An integer that specifies the first character to replace. The first character position is 0 (zero). This
parameter is optional.
endIndex
An integer that specifies the last character to replace. This parameter is optional.
Returns
A Boolean value:
true
if the text of at least one text string is set;
false
otherwise.
Description
Method; inserts a string of text. If the optional parameters are not passed, the existing text selection is replaced; if the
Text object isn’t currently being edited, the whole text string is replaced. If only startIndex is passed, the string passed
is inserted at this position. If startIndex and endIndex are passed, the string passed replaces the segment of text starting
from startIndex up to, but not including, endIndex.
Example
The following example replaces the current text selection with “Hello World”:
var success = fl.getDocumentDOM().setTextString("Hello World!");
The following example inserts “hello” at position 6 of the current text selection:
var pass = fl.getDocumentDOM().setTextString("hello", 6);