AS3.0: Add one or more elements to the begining of an array

November 7, 2008 at 5:00 pm (ActionScript) (, )

Written for: ActionScript 3.0

To add one or more elements to the begining of an array, you will have to use unshift method of Array class.

Below is an example.

var albums:Array = new Array("Natty Dread","Rastaman Vibration","Exodus","Kaya");
albums.unshift("Catch A Fire");

trace(albums); //Catch A Fire,Natty Dread,Rastaman Vibration,Exodus,Kaya

Permalink Leave a Comment