For - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

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 example uses
adds the numbers from 1 to 100.
var sum:Number = 0;
for (var i:Number = 1; i<=100; i++) {
sum += i;
}
trace(sum);
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
to perform the same action repeatedly. In the code, the
for
// output: 5050
ActionScript Language Reference
or
. The condition is evaluated before
true
false
expression. If the
condition
expression is evaluated. The looping
next
condition
CHAPTER 2
.
false
expression
condition
expression.
statement
for
loop
for
for
301

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents