Using operators to manipulate values in expressions
35
The following table lists the ActionScript comparison operators:
String operators
The addition (+) operator has a special effect when it operates on strings: It concatenates the two
string operands. For example, the following statement adds
"Congratulations,"
to
"Donna!"
:
"Congratulations, " + "Donna!"
The result is
"Congratulations, Donna!"
If only one of the addition (
+
) operator’s operands is
a string, Flash converts the other operand to a string. ActionScript treats spaces at the beginning
or end of a string as a literal part of the string.
The comparison operators
>
,
>=
,
<
, and
<=
also have a special effect when operating on strings.
These operators compare two strings to determine which is first in alphabetical order.
The comparison operators compare strings only if both operands are strings. If only one of
the operands is a string, ActionScript converts both operands to numbers and performs a
numeric comparison. Uppercase characters precede lowercase in alphabetic order, so “Eagle”
comes before “dog.” If you want to compare two strings or characters regardless of case, you need
to convert both strings to upper- or lowercase before comparing them.
Operator
Operation performed
<
Less than: Returns
true
if the left operand is mathematically smaller than the right
operand.
Returns
true
if the left operand alphabetically precedes the right operand (for
example, a < b).
>
Greater than: Returns
true
if the left operand is mathematically larger than the right
operand.
Returns
true
if the left operand alphabetically follows the right operand (for example,
b > a).
<=
Less than or equal to: Returns
true
if the left operand is mathematically smaller than
or the same as the right operand.
Returns
true
if the left operand alphabetically precedes or is the same as the right
operand.
>=
Greater than or equal to: Returns
true
if the left operand is mathematically larger than
or the same as the right operand.
Returns
true
if the left operand alphabetically follows or is the same as the right
operand.
<>
!=
Not equal: Returns
true
if the operands are not mathematically equivalent.
Returns
true
if the operands are not the same.
==
Equality: Tests two expressions for equality. The result is
true
if the expressions are
equal.
===
Strict equality: Tests two expressions for equality; the strict equality operator performs
the same as the equality operator except that data types are not converted. The result
is
true
if both expressions, including their data types, are equal. Does not apply to
strings.
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 ...