Creating Arrays


In ActionScript, an array is actually an object. (In Chapter 6, "Objects: Critter Attack ," we'll look at objects in great detail.) To use an array, the first thing we must do is create one. Look at the following code that creates a new array:

 myArray = new Array(); 

This line of script begins with a new variable declaration: myArray . From there, this new reference is assigned a value of new Array() . All this does is create a new array object and assign it to the reference myArray . The parentheses following the object name are for constructors, and we'll talk about those in Chapter 6 as well. For now, just realize that the preceding script creates a new array for our use.

Caution  

The keyword new is reserved in Flash. Its sole purpose is object instantiation.




Macromedia Flash MX 2004 Game Programming
Macromedia Flash MX 2004 Game Programming (Premier Press Game Development)
ISBN: 1592000363
EAN: 2147483647
Year: 2004
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net