Here are the first 5 paragraphs of Chapter 11 of Essential ActionScript 3.0
11. Arrays
Arrays are used to store and manipulate ordered lists of information and are, therefore, a fundamental tool in sequential, repetitive programming. We use arrays to do everything from storing user input, to generating pull-down menus, to keeping track of enemy spacecraft in a game. Practically speaking, an array is just a list of items, like your grocery list or the entries in your checkbook ledger. The items just happen to be ActionScript values.
What Is an Array?
An array is a data structure that can encompass multiple individual data values in an ordered list. Here is a simple example showing two separate strings, followed by an array that contains two strings:
"cherries" // A single string
"peaches" // Another string
["oranges", "apples"] // A single array containing two strings
An array can contain any number of items, including items of different types. An array can even contain other arrays. Here is a simple example showing an array that contains both strings and numbers. It might represent your shopping list, showing how many of each item you intend to buy:
["oranges", 6, "apples", 4, "bananas", 3];
Though an array can keep track of many values, it’s important to recognize that the array itself is a single data value. Arrays are represented as instances of the Array class. As such, an array can be assigned to a variable or used as part of a complex expression:
// Assign an array to a variable
var product:Array = ["ladies downhill skis", 475];
// Pass that array to a function
display(product);
Each item in an array is called an array element, and each element has a unique numeric position (index) by which we can refer to it.
Posted by moock at March 29, 2007 07:39 PM