TextField.restrict
745
Description
Method; replaces a range of characters, specified by the
beginIndex
and
endIndex
parameters, in
the specified text field with the contents of the
text
parameter.
Example
The following example creates a text field called
my_txt
and assigns the text [email protected] to
the field. The
indexOf()
method is used to find the first occurrence of the specified symbol (
@
).
If the symbol is found, the specified text (between the index of 0 and the symbol) replaces with
the string
bird
. If the symbol is not found, an error message writes to the log file.
this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 22);
my_txt.autoSize = true;
my_txt.text = "[email protected]";
var symbol:String = "@";
var symbolPos:Number = my_txt.text.indexOf(symbol);
if (symbolPos>-1) {
my_txt.replaceText(0, symbolPos, "bird");
} else {
trace("symbol '"+"' not found.");
}
TextField.restrict
Availability
Flash Player 6.
Usage
my_txt
.restrict
:String
Description
Property; indicates the set of characters that a user may enter into the text field. If the value of the
restrict
property is
null
, you can enter any character. If the value of the
restrict
property is
an empty string, you can’t enter any character. If the value of the
restrict
property is a string of
characters, you can enter only characters in the string into the text field. The string is scanned
from left to right. A range may be specified using the dash (-). This only restricts user interaction;
a script may put any text into the text field. This property does not synchronize with the Embed
Font Outlines check boxes in the Property inspector.
If the string begins with ^, all characters are initially accepted and succeeding characters in the
string are excluded from the set of accepted characters. If the string does not begin with ^, no
characters are initially accepted and succeeding characters in the string are included in the set of
accepted characters.
Example
The following example allows only uppercase characters, spaces, and numbers to be entered into
a text field:
my_txt.restrict = "A-Z 0-9";
Summary of Contents for FLEX
Page 1: ...Flex ActionScript Language Reference ...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0 ...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally ...
Page 135: ...case 135 See also break default strict equality switch ...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while ...
Page 808: ...808 Chapter 7 ActionScript for Flash ...
Page 810: ...810 Appendix A Deprecated Flash 4 operators ...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code ...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values ...
Page 822: ...822 Index ...