Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 90

Programming actionscript 3.0
Table of Contents

Advertisement

You can also iterate through the elements of an array, as this example shows:
var myArray:Array = ["one", "two", "three"];
for each (var item in myArray)
{
trace(item);
}
// output:
// one
// two
// three
You cannot iterate through the properties of an object if the object is an instance of a sealed
class. Even for instances of dynamic classes, you cannot iterate through any fixed properties,
which are properties defined as part of the class definition.
while
The
loop is like an
while
example, the following code produces the same output as the
var i:int = 0;
while (i < 5)
{
trace(i);
i++;
}
One disadvantage of using a
to write with
loops. The
while
expression that increments the counter variable, but the
you omit that step. Without the expression that increments
loop.
do..while
The
loop is a
do..while
once, because the condition is checked after the code block is executed. The following code
shows a simple example of a
is not met:
var i:int = 5;
do
{
trace(i);
i++;
90
ActionScript Language and Syntax
statement that repeats as long as the condition is
if
loop instead of a
while
loop example code does not compile if you omit the
for
loop that guarantees that the code block is executed at least
while
loop that generates output even though the condition
do..while
loop example:
for
loop is that infinite loops are easier
for
loop example does compile if
while
, the loop becomes an infinite
i
. For
true

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents