Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 86

Programming actionscript 3.0
Table of Contents

Advertisement

if..else if
You can test for more than one condition using the
example, the following code not only tests whether the value of
whether the value of
if (x > 20)
{
trace("x is > 20");
}
else if (x < 0)
{
trace("x is negative");
}
If an
or
statement is followed by only one statement, the statement does not need to
if
else
be enclosed in braces. For example, the following code does not use braces.
if (x > 0)
trace("x is positive");
else if (x < 0)
trace("x is negative");
else
trace("x is 0");
However, Adobe recommends that you always use braces because unexpected behavior can
occur if statements are later added to a conditional statement that lacks braces. For example,
in the following code the value of
evaluates to
:
true
var x:int;
var positiveNums:int = 0;
if (x > 0)
trace("x is positive");
positiveNums++;
trace(positiveNums); // 1
86
ActionScript Language and Syntax
is negative:
x
positiveNums
conditional statement. For
if..else if
exceeds 20, but also tests
x
increases by 1 whether or not the condition

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents