Chapter 6. Arrays
Arrays are essential to successful ActionScript programming. At its most basic, an array can be thought of as a series of variables that can be referred to using a single, common name, which is often easier than having separate variable names for each datum. And what’s more, the data in an array is ordered and enumeratable, providing a convenient way to organize, sort, and access the values.
Arrays provide a way of grouping together, organizing, and processing related data elements. The concept of an array should not be foreign to you. If fact, we use the concept of arrays in everyday life all the time. A simple grocery list or to-do list can be thought of as an array. Your address book is an array containing people’s names and addresses. Libraries keep track of books using an indexing system whereby each book becomes, conceptually, an element in a library’s array. You’ll ordinarily use arrays to hold a series of related items, such as playing cards in a deck, as seen in Recipe 5.10.
In ActionScript, there are
associative. Unless otherwise specified, the
term “array” usually refers to an
integer-indexed array. Both types of arrays group together related
data, but they use different means of accessing the data. An
integer-indexed array uses integers (numbers) as unique identifiers
for each element in the array. Such arrays are ordered by
index (i.e., element number), starting from 0. Each element occupies a numbered ...