Loops

A for loop is a good choice when we know how many times we want the code to repeat.

The format for a for loop is: for ( initialize list; Boolean expression to continue; execute at end) statement or block of statements;
Example: Start a new flash movie and write the code shown below in the Actions panel. Notice that we can declare a variable inside a for statement:

for(var num:int=0; num<=5; num++) {
  trace(num);
}  //loop

When you test the movie you will see the numbers 0 to 5 in the output window.
Notice the indentation: all statement within { and } are indented the same amount for readability.

NEXT: do while Loops