ActionScript tutorial  
  Home Computer Graphics Tutorials Tutorials Web Design tutorials Forums Computer Graphics Community Interview Interview Articles Articles Making Making About About US Contact us
 
*Home / Tutorials / Adobe Flash / ActionScript Arrays
     
Maya tutorials   Autodesk Maya
Photoshop tutorials   Adobe Photoshop
Illustrator tutorials   Adobe Illustrator
flash tutorials   Adobe Flash
3Ds max tutorials   Autodesk 3D's Max
Premiere tutorials   Adobe Premiere
Dreamweaver tutorials   Adobe Dreamweaver
*
 

ActionScript Arrays


Author: Animator
Level : Beginner
Environment : Adobe Flash MX Professional 2004
* * * * *
 
 

ActionScript Arrays

An array is a group of similar data typed variables that shares a common name. Arrays are a very useful when you want to group data. A specific element in an array is accessed by its index. Always the first index of an array will be zero and the last elements index will be one less than the size of the array.

You can construct an array in two ways. 1. By using the square brackets syntax and 2. By using the new Array() construct.

1. Square bracket syntax.
You can create an array from scratch using the combination of square bracket and commas. For eg:

var myArray = [10,20,30,40,50];

The above array myArray is having a size of five elements with 10 as the first element i.e., the element at index zero and 50 as the last element i.e., the element at index 4.

To access any element of the array we can use the index. For eg: to get the third element of myArray

myArray[2];
This would return a value of 30.
2. Using new Array() syntax.
The second way of creating an array is using the new Array() syntax. For eg:
var myArray = new Array();

To insert a new element to the array we can use the push method. Push always insert an element to the end of the array. For eg:
myArray.push(10);
myArray.push(20);

Array provides a set of convenient properties and methods to manipulate an array. For eg: arrays are having a property called length which returns the length of the array.
 
 
 
  Bookmark   Googlize this * Add to Yahoo * Add To_Delicious * Digg It * Scrutinize this * Spurl this * Furl * Socializer * Onlywire
     
  Discuss This   Add to Any * Add this * Blink It *
 
*

Home | Tutorials | Forums | Interviews | Articles | Making | About the Team | Terms and Conditions | Privacy Policy | Contact us
Copyright © 2006-2007 CGShelf.com. All Rights Reserved