EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 172

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
172 Syntax and Language Fundamentals
4. Select Control > Test Movie to view the elements that are displayed in the Output panel.
You will see the following in the Output panel:
[0][0]
[0][1]
[0][2]
[1][0]
[1][1]
[1][2]
[2][0]
[2][1]
[2][2]
For information on using arrays, see “Using arrays” on page 164. For information on array
elements, see About adding and removing elements” on page 168. For information on the
array access operator, see “Using dot and array access operators” on page 184.
Creating associative arrays
An associative array, which is like an object, is made of unordered keys and values. Associative
arrays use keys instead of a numeric index to organize stored values. Each key is a unique
string, and it is associated with and used to access one value. That value can be a data type
such as Number, Array, Object, and so on. When you create code to find a value thats
associated with a key, you are indexing or performing a lookup. This is what you will probably
use associative arrays for most often.
The association between a key and value is commonly referred to as its binding; the key and
value are mapped to each other. For example, a contact book might be considered an
associative array, where the names are the keys and email addresses are the values
When you use associative arrays, you can call the array element you need using a string rather
than a number, which is often easier to remember. The downside is that these arrays aren't as
useful in a loop because they do not use numbers as the index value. They are useful when you
need to look up by key values frequently. For example, if you had an array of names and ages
that you needed to refer to a lot, you might use an associative array.
The following example demonstrates how to create an object and define a series of properties
in an associative array.
To create a simple associative array:
1. Create a new Flash document.
NOTE
Associative arrays are unordered collections of key and value pairs. Your code should
not expect the keys of an associative array to be in a specific order.

Table of Contents

Related product manuals