ActionScript 2.0 Components Language Reference |
|
|
|
| TextArea component > TextArea.restrict | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
textAreaInstance.restrict
Property; indicates the set of characters that users can enter in the text area. The default value is undefined. If this property is null, users can enter any character. If this property is an empty string, no characters can be entered. If this property is a string of characters, users can enter only characters in the string; the string is scanned from left to right. You can specify a range by using a dash (-).
If the string begins with ^, all characters that follow the ^ are considered unacceptable characters. If the string does not begin with ^, the characters in the string are considered acceptable. The ^ can also be used as a toggle between acceptable and unacceptable characters.
For example, the following code allows A-Z except X and Q:
Ta.restrict = "A-Z^XQ";
Restricting input to uppercase characters converts alphabetic characters entered in lowercase to uppercase. Likewise, restricting input to lowercase characters converts characters entered in uppercase to lowercase.
The restrict property only restricts user interaction; a script may put any text into the text area. This property does not synchronize with the Embed Font Outlines check boxes in the Property inspector.
The following example first sets the restrict property to limit the text area to uppercase letters, numbers, and spaces, and then sets it to allow all characters except lowercase letters.
You must first add an instance of the TextArea component to the Stage and name it my_ta; then add the following code to Frame 1. Use only one setting for the restrict property at a time.
/** Requires: - TextArea instance on Stage (instance name: my_ta) */ var my_ta:mx.controls.TextArea; my_ta.wordWrap = true; // Limit control to uppercase letters, numbers, and spaces. my_ta.restrict = "A-Z 0-9"; // Allow all characters, except lowercase letters // characters to uppercase my_ta.restrict = "^a-z";
|
|
|
|