Name

Array Class — support for ordered lists of data

Availability

Flash 5

Constructor

new Array( )
new Array(len)
new Array(element0, element1, element2,...elementn)

Arguments

len

A non-negative integer specifying the size of the new array.

element0,...elementn

A list of one or more initial values to be assigned as elements of the array.

Properties

length

The number of elements in an array (including empty elements).

Methods

concat( )

Create a new array by appending additional elements to an existing array.

join( )

Convert an array to a string.

pop( )

Remove and return the last element of an array.

push( )

Add one or more elements to the end of an array.

reverse( )

Reverse the order of elements in an array.

shift( )

Remove and return the first element of an array.

slice( )

Create a new array using a subset of elements from an existing array.

sort( )

Sort the elements of an array according to the specified rule.

splice( )

Remove elements from, and/or add elements to, an array.

toString( )

Convert an array to a string of comma-separated element values.

unshift( )

Add one or more elements to the beginning of an array.

Description

We use the properties and methods of the Array class to manipulate the data stored in the elements of an array object. See Chapter 11, for exhaustive details on what arrays are and how you can use them, plus detailed definitions of the terminology used in this section. See also the [] and . operators, which are used to access array elements as described in Chapter 5.

Usage

If the Array constructor ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.