Flex Arrays


 

Flex Arrays

An array is a collection of elements. These elements can be accessed by indexing starting from 0.

An array is a collection of elements. These elements can be accessed by indexing starting from 0.
An array is a collection of elements. These elements can be accessed by indexing starting from 0. Flex provides Array class to work with arrays. Array can store dissimilar type of elements like string, number etc.

Declaration and assignment simultaneously:

var myArray:Array = {"RoseIndia", 10, new MyClass()};


Declaration and assignment separately:

var myArray:Array = new Array();

myArray[0] = "RoseIndia";

myArray[1] = 10;

myArray[2] = new MyClass();


You can add any element to the end of the array using push() method and remove the last element by pop() method.

//push() adds the element in the last of the arraymy
Array.push(
"RoseIndia");

// pop() removes the last element from the array.
myArray.pop();

Ads