You can use the backslash (
) to enter a hyphen (
), caret (
), or backslash (
) character, as
\
-
^
\
shown here:
\^
\-
\\
When you enter a backslash in the Actions panel within double quotation marks, it has a
special meaning for the Actions panel's double-quote interpreter. It signifies that the character
following the backslash should be treated "as is." For example, you could use the following
code to enter a single quotation mark:
var leftQuote = "\'";
The Actions panel's restrict interpreter also uses the backslash as an escape character.
Therefore, you may think that the following should work:
myText.restrict = "0-9\-\^\\";
However, since this expression is surrounded by double quotation marks, the value
is
0-9-^\
sent to the restrict interpreter, and the restrict interpreter doesn't understand this value.
Because you must enter this expression within double quotation marks, you must not only
provide the expression for the restrict interpreter, but you must also escape the expression so
that it will be read correctly by the Actions panel's built-in interpreter for double quotation
marks. To send the value
to the restrict interpreter, you must enter the
0-9\-\^\\
following code:
myCombo.restrict = "0-9\\-\\^\\\\";
The
property restricts only user interaction; a script may put any text into the text
restrict
field. This property does not synchronize with the Embed Font Outlines check boxes in the
Property inspector.
Example
With a ComboBox component instance
, the following ActionScript restricts the entry
my_cb
of characters to numbers 0-9, dashes, and dots:
// Add Items to List.
my_cb.addItem({data:1, label:"First Item"});
my_cb.addItem({data:2, label:"Second Item"});
// Enable editing of combo box.
my_cb.editable = true;
// Restrict the characters that can be entered into combo box.
my_cb.restrict = "0-9\\-\\.\\ ";
ComboBox.restrict
195
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers