Chapter 8. Using Arrays
In this chapter
Working with indexed arrays, associative arrays, and dictionaries
Adding content to your array
Using arrays as queues and stacks
Searching for values within your array
Sorting the elements in your array
Performing actions on all elements within an array
In this chapter, we look at arrays. Arrays are a type of ordered set of data like a numbered list. By using an array, you can store any number of individual pieces of data in a single variable, which allows you to group values that should go together. The Array class also provides methods and properties that allow you to work with this set of data by editing it, searching through it, sorting it, and operating on the entire group. Arrays are used frequently in nearly all programming languages and ActionScript is no exception.
Arrays are the first complex data type that we study in Part II of this book. strings, numbers, Booleans, and the like are all primitive data types—which means they are the core building blocks of information and usually contain a single piece of immutable data of a specific type. Complex data types, on the other hand, are composites of the various primitive types.
As we said, arrays are a lot like a numbered list of items. Each item, or element, in an array has a location, or index. Unlike most numbered lists, indexes in an array start at 0 instead of 1. These indexes are used to look up elements in the array, as shown in Figure 8-1 .
Figure 8.1. Figure ...