Actionscript
3.0 Lesson Five: Arrays
1.)In
this tutorial I will show you how to set up an Array.
An Array is basically a list of variables. Such as a
shopping list, or a list of numbers. You can make an
Array of integers, or any type of variable, even an
Array of Arrays. Those are called 2D Arrays, Or you
can even have an Array of Movie Clips. I will provide
an example. You can test this by pasting this into an
actionscript 3.0's documents frame.
var
myArray:Array = ([1,2,3,4,"myString"]);
trace(myArray);
|
---------
--------------
---------
--------------
|
2.)
The break Down. First you must initilize it like any other variable, then put the list in parenthesis. Then place a semicolon after inilizing it to say you have created a statement of setting up an array. Then in the trace function it calls the Array and opens up a dialog box of all the things in your array.
You can add or delete things to your list in your Array by using a push statement, or delete items in your Array with a splice command. Here is an example, you can test this by pasting it into a frame in an actionscript 3.0's document.
} |
|
3.)
Here
is the code.
var
myArray:Array = ([1,2,3,4,"myString"]);
myArray.push("some text");
myArray.splice(2,1);
Here is a list of Common Array Functions, with descriptions
and examples.
List
of Array Functions
|
-jordan |
|