Chapter 14. Iteration and Repetition

Looping logic consists of iteration and repetition. Loops are control structures used to count (iterate) through a data structure. With loops, we can write code once and use it many times to repeat a set of actions. Loops allow us to accommodate for variations in data that we simply cannot plan for ahead of time. For instance, an array in an application may begin with three elements. After certain events take place in the application, the array length grows to five elements.

We do not know what scenarios might take place ahead of time, so it’s hard for us to program the number of elements to get from an array if we do not know the array’s length. Loops handle those types of scenarios for us, so we do not have ...

Get ActionScript 3.0: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.