Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
With looping statements, you can create an action or set of actions that repeats. For example, you may have actions repeat a certain number of times or as long as a certain condition holds true. Repeating actions are often used together with an array, which is a special kind of object that holds multiple values in a structured, easily accessible way. Using a looping action lets you add or retrieve the pieces of data in a particular order. You’ll learn more about arrays in Chapter 11.
In general, use looping statements to execute actions automatically a specific number of times by using an incrementing counter variable. The counter variable is used in parameters of methods called in the loop or to modify properties of objects that are created. For example, you can generate intricate patterns by duplicating dynamically drawn shapes with looping statements. Use looping statements to change the properties of a whole series of DisplayObjects, modify multiple sound settings, or alter the values of a set of variables.