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
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...