Share on Google+Share on Google+

Flex Arrays

Advertisement
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();

Advertisements

Advertisement

Posted on: April 19, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.