MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 157

Actionscript language reference
Table of Contents

Advertisement

for
Availability
Flash Player 5.
Usage
for(init; condition; next) {
statement(s);
}
Parameters
An expression to evaluate before beginning the looping sequence; usually an assignment
init
expression. A
var
An expression that evaluates to
condition
each loop iteration; the loop exits when the condition evaluates to
An expression to evaluate after each loop iteration; usually an assignment expression using
next
the increment (
++)
statement(s)
Description
Statement; evaluates the
looping sequence begins by evaluating the
evaluates to true,
sequence then begins again with the evaluation of the
The curly braces (
are not necessary if only one statement will execute.
Example
The following example uses
var my_array:Array = new Array();
for (var i:Number = 0; i<10; i++) {
my_array[i] = (i+5)*10;
//trace(my_array[i]);
}
trace(my_array);
The following results are written to the log file:
50
60
70
80
90
100
110
120
130
140
ActionScript Core Language Elements
statement is also permitted for this parameter.
or decrement (
) operators.
--
An instruction or instructions to execute within the body of the loop.
(initialize) expression once and then starts a looping sequence. The
init
is executed and the
statement
) used to enclose the block of statements to be executed by the
{}
to add the elements in an array:
for
// output: 50,60,70,80,90,100,110,120,130,140
or
. The condition is evaluated before
true
false
expression. If the
condition
expression is evaluated. The looping
next
condition
CHAPTER 5
.
false
expression
condition
expression.
statement
for
for
157

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents