|| (logical OR)
Availability
Flash Player 4.
Usage
expression1 || expression2
Parameters
expression1, expression2
value.
Returns
A Boolean value.
Description
Operator (logical); evaluates
returns
if the expression evaluates to
true
(the expression on the right side of the operator) is evaluated. If
expression2
evaluates to
false
If you use a function call as
evaluates to true.
expression1
The result is
true
expressions evaluate to
if any operand evaluates to
For more information, see "Operator precedence and associativity" in Using ActionScript in Flash.
Example
The following example uses the logical OR (
expression evaluates to
var x:Number = 10;
var y:Number = 250;
var start:Boolean = false;
if ((x>25) || (y>200) || (start)) {
trace("the logical OR test passed"); // output: the logical OR test passed
}
The message
the logical OR test passed
statement is true (
condition evaluates to
The following example demonstrates how using a function call as
unexpected results. If the expression on the left of the operator evaluates to
returned without evaluating the expression on the right (the function
function fx1():Boolean {
trace("fx1 called");
return true;
A Boolean value or an expression that converts to a Boolean
expression1
, the final result is
false
expression2
if either or both expressions evaluate to
. You can use the logical OR operator with any number of operands;
false
, the result is
true
so the final result is
true,
). Although the other two expressions evaluate to
y>200
the
block executes.
true,
if
(the expression on the left side of the operator) and
. If
true
expression1
; otherwise, it is
true
, the function will not be executed by that call if
; the result is
true
.
true
) operator in an
||
if
:
true
appears because one of the conditions in the
evaluates to
,
false
expression2
.
only if both
false
statement. The second
, as long as one
false
can lead to
expression2
, that result is
true
is not called).
fx2()
|| (logical OR)
if
65
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?