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 appears because one of the conditions in the
statement is true (
y>200
one 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;
}
function fx2():Boolean {
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
See also
! logical NOT operator
,
operator
&& logical AND operator
operator
or logical OR operator
condition1 or condition2
Deprecated since Flash Player 5. This operator was deprecated in favor of the
operator.
OR)
Evaluates
condition1
is
.
true
176
ActionScript language elements
so the final result is
true,
). Although the other two expressions evaluate to
the
block executes.
true,
if
,
!= inequality operator
,
== equality operator
and
, and if either expression is
condition2
) operator in an
||
if
:
true
,
!== strict inequality
statement. The second
if
, as long as
false
can lead to
expression2
, that result is
true
is not called).
fx2()
,
=== strict equality
|| (logical
, the whole expression
true
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?