Array Class

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Array Class Flash 5; sortOn( ) method added in Flash 6

support for ordered lists of data

Constructor

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

Arguments

len

A nonnegative 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 the elements of an array to strings, and concatenate using a customizable delimiter.

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.

sortOn( )

Sort an array of objects by the specified property.

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 dot operators, which are used to access array elements and form array literals, as described in Chapter 5.

Usage

If the Array constructor is invoked with a single integer argument, that argument is used to set the length of the new array, which is then filled with undefined values. If two or more arguments are supplied to the constructor or if a single nonnumeric argument is supplied to the constructor, the arguments are used as the initial values for elements in the array, and the length of the array is determined by the number of arguments specified.

     



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net