
Using operators to manipulate values in expressions
47
Logical operators
Logical operators compare Boolean values (
true
and
false
) and return a third Boolean value.
For example, if both operands evaluate to
true
, the logical AND operator (
&&
) returns
true
. If
one or both of the operands evaluate to
true
, the logical OR operator (
||
) returns
true
. Logical
operators are often used with comparison operators to determine the condition of an
if
action.
For example, in the following script, if both expressions are true, the
if
action will execute:
if (i > 10 && _framesloaded > 50){
play();
}
The following table lists the ActionScript logical operators:
Bitwise operators
Bitwise operators internally manipulate floating-point numbers to change them into 32-bit
integers. The exact operation performed depends on the operator, but all bitwise operations
evaluate each binary digit (bit) of the 32-bit integer individually to compute a new value.
The following table lists the ActionScript bitwise operators:
Equality operators
You can use the equality (
==
) operator to determine whether the values or identities of two
operands are equal. This comparison returns a Boolean (
true
or
false
) value. If the operands are
strings, numbers, or Boolean values, they are compared by value. If the operands are objects or
arrays, they are compared by reference.
It is a common mistake to use the assignment operator to check for equality. For example, the
following code compares
x
to 2:
if (x == 2)
In that same example, the expression
x = 2
is incorrect because it doesn’t compare the operands,
it assigns the value of 2 to the variable
x
.
Operator
Operation performed
&&
Logical AND
||
Logical OR
!
Logical NOT
Operator
Operation performed
&
Bitwise AND
|
Bitwise OR
^
Bitwise XOR
~
Bitwise NOT
<<
Shift left
>>
Shift right
>>>
Shift right zero fill
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...