ActionScript Arrays

Actionscript array is a collection of data stored within an object. For example we can store 5 names of students into their 

Arrays uses a datatype know as Array. Because an array is an object or instance in actionscript that's why we are going to use a keyword "new". ActionScript has a class for array known as Array.

To create a new array object in actionscript we use the following syntax

var arrayName:ArrayDataType = new ArrayClassConstructor();

A practicle example of array in actionscript is given here

//Declare an Array
var myArray:Array = new Array();

//Store values in this array
myArray[0] = 10;
myArray[1] = 20;
trace(myArray[1]);

//this will result 10

ActionScript Array Length

length can be used with array to calculate the total elements stored in an array.

//Declare an Array
var myArray:Array = new Array();

//Store values in this array
myArray[0] = 10;
myArray[1] = 20;
trace(myArray.length);

//this will result 2

ActionScript Array push

Actionscript push is a method that can be used to store data into an array

//Declare an Array
var myArray:Array = new Array();

//Store values in this array
myArray.push(40);
trace(myArray[0]);

//this will result 40