182
Syntax and Language Fundamentals
About using operators with strings
Comparison operators compare strings only if both operands are strings. An exception to this
rule is the strict equality (
===
) operator. If only one operand is a string, ActionScript converts
both operands to numbers and performs a numeric comparison on them. For more
information on numeric operators, see
“Using numeric operators” on page 188
.
Except for the equality operator (
==
), comparison operators (
>
,
>=
,
<
, and
<=
) affect strings
differently than when they operate on other values.
Comparison operators compare strings to determine which is first alphabetically. Strings with
uppercase characters precede strings that are lowercase. That means that "Egg" comes before
"chicken".
var c:String = "chicken";
var e:String = "Egg";
trace(c < e); // false
var riddleArr:Array = new Array(c, e);
trace(riddleArr); // chicken,Egg
trace(riddleArr.sort()); // Egg,chicken
<=
Less than or equal to
Left to right
>
Greater than
Left to right
>=
Greater than or equal to
Left to right
==
Equal
Left to right
!=
Not equal
Left to right
&
Bitwise AND
Left to right
^
Bitwise XOR
Left to right
|
Bitwise OR
Left to right
&&
Logical AND
Left to right
||
Logical OR
Left to right
?:
Conditional
Right to left
=
Assignment
Right to left
*=, /=, %=, +=, -
=, &=, |=, ^=,
<<=, >>=, >>>=
Compound assignment
Right to left
,
Comma
Left to right
Lowest precedence
Operator
Description
Associativity
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...