EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 250

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
250 Chapter 12: ActionScript Dictionary
Description
Operator (logical); evaluates expression1 and expression2. The result is true if either or both
expressions evaluate to
true; the result is false only if both expressions evaluate to false. You
can use the logical OR operator with any number of operands; if any operand evaluates to
true,
the result is
true.
With non-Boolean expressions, the logical OR operator causes Flash to evaluate the expression on
the left; if it can be converted to
true, the result is true. Otherwise, it evaluates the expression on
the right and the result is the value of that expression.
Example
Usage 1: The following example uses the || operator in an if statement. The second expression
evaluates to
true so the final result is true:
x = 10
y = 250
start = false
if(x > 25 || y > 200 || start){
trace('the logical OR test passed');
}
Usage 2: This example demonstrates how a non-Boolean expression can produce an unexpected
result. If the expression on the left converts to
true, that result is returned without converting the
expression on the right.
function fx1(){
trace ("fx1 called");
returns true;
}
function fx2(){
trace ("fx2 called");
return true;
}
if (fx1() || fx2()){
trace ("IF statement entered");
}
// The following is sent to the Output panel:
// fx1 called
// IF statement entered
|= (bitwise OR assignment)
Availability
Flash Player 5.
Usage
expression1 |= expression2
Parameters
expression1,expression2
A number or variable.
Returns
None.

Table of Contents

Related product manuals