AS3 Arrays: Access objects inside an array

Add five button components to the stage.

Give first button an instance name of bButton1.
Give second button an instance name of bButton2.
Give third button an instance name of bButton3.
Give fourth button an instance name of bButton4.
Give last button an instance name of bButton5.

Actionscript:

var aButtons:Array = new Array (bButton1, bButton2, bButton3, bButton4, bButton5);

trace(aButtons);
//returns the contents of the array
trace(aButtons[1].name);
//trace the name of object in specific position in an array. Index position must be in brackets. This trace would return "bButton2".
trace(aButtons[1].label);
//trace the label of object in specific position in an array. Index position must be in brackets. This trace would return the label of your second button.
trace(aButtons.length);
//returns the length of the array. This trace would return "5"

AS3 Arrays: Access elements in a string array

//String array

Example

var aString:Array = new Array ("Name", "Address", "State", "Zip", "Phone");
trace(aString);
//returns the contents of the array
trace(aString[1]);
//trace the position of an object in an array. Index position must be in brackets. This trace would return "address".
trace(aString.length);
//returns the length of the array. This trace would return "5"

AS3 Arrays: Array breakdown

var testArray:Array=new Array("name","address","state","zip","country");
//Naming the array variable

var testArray:Array=new Array("name","address","state","zip","country");
//Datatyping the variable as an Array

var testArray:Array=new Array("name","address","state","zip","country");
//Setting up a new array

var testArray:Array=new Array("name","address","state","zip","country");
//contents of the array. Each item is assigned a numerical index starting with 0. The example above would be (0,1,2,3,4).