Array Declaration

The Array class lets you access and manipulate arrays. Array indices are zero-based, which means that the first element in the array is [0], the second element is [1], and so on.

Different Way of Declaring and storing Arrays

First Method

var Ar:Array=new Array()
Ar[0]=”Orange”
Ar[1]=”Apple”
trace(Ar) // Returns Orange, Apple
trace(Ar[0]) //Returns Orange

Second Method

var Ar:Array=new Array(“Orange”,”Apple”)
trace(Ar) // Returns Orange, Apple
trace(Ar[0]) //Returns Orange

Third Method

var Ar:Array=new Array()
Ar.push(“Orange”)
Ar.push(“Apple”)
trace(Ar) //Orange, Apple

Fourth Method

var Ar:Array=new Array()
Ar.push(“Orange”,”Apple”)
trace(Ar) // Orange, Apple

Fifth Method

var Ar=[]
Ar.push(“Orange”,”Apple”)
trace(Ar) // Orange, Apple

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.