TextField.replaceText()
Availability
Flash Player 7.
Usage
my_txt.replaceText(beginIndex:Number, endIndex:Number, text:String) : Void
Description
Method; replaces a range of characters, specified by the
the specified text field with the contents of the
Example
The following example creates a text field called
the field. The
indexOf()
If the symbol is found, the specified text (between the index of 0 and the symbol) replaces with
the string
. If the symbol is not found, an error message is displayed in the Output panel.
bird
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 22);
my_txt.autoSize = true;
my_txt.text = "dog@house.net";
var symbol:String = "@";
var symbolPos:Number = my_txt.text.indexOf(symbol);
if (symbolPos>-1) {
my_txt.replaceText(0, symbolPos, "bird");
} else {
trace("symbol '"+symbol+"' not found.");
}
912
Chapter 2: ActionScript Language Reference
text
method is used to find the first occurrence of the specified symbol (
and
beginIndex
parameter.
and assigns the text dog@house.net to
my_txt
parameters, in
endIndex
@
).
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?