July 2009
Intermediate to advanced
384 pages
9h 22m
English
Frequently, you will need to perform repetitive tasks in your scripts. Like other programming languages, ActionScript provides for several different methods of looping over a block of code.
One of the most common types of loops is a for loop. To initialize the loop, you need to provide three key elements: the counter variable for the loop, the condition on which the loop will be tested, and a statement to change the value of the counter with each iteration of the loop. Following the initialization line, you will place the code to be executed with each iteration within a set of curly braces. For example, your loop might look like this:
for(var i:Number=0; i<10; i++)
{
trace(i);
}In this example, a variable, ...
Read now
Unlock full access