This tutorial will cover one of the most interesting and powerful Variable Types in Actionscript,"The Arrays.
Well to get this Simple for you , the Array is an Object that lets you save, access and manipulate the content of the Arrays.
The Array is an object whose properties are identified by a number representing their position in the array, this Number is referred by "index", All Array starts with the Index 0.
and there is no better than example to clarify this, I will Create an Array Called ourArray.


ourArray[0] = "Monday"
ourArray[1] = "Tuesday"
ourArray[2] = "Wednesday"
ourArray[3] = "Thursday"

Now let's discuss what we can do with this Arrays, Normally Arrays stores a lot different data from Strings , Integers , Complex object to Arrays , which means that you can create a multi-dimension Array by inserting an Array into another.
This is an Array holding a different type of Variable.

//lets create ourArray
var ourArray = new Array("I am String into my our Array" );

//lets create myArray
myArray[0] = "I am a String";
myArray[1] = 5; // I am a number.
myArray[2] = ourArray ; // I am an Array

trace(myArray[2][0]); // The output will be "I am String into my our Array".


The Array Object has several method for manipulating the array.
Array.concat : Concatenates the parameters and returns them as a new array. Example:

num1=[1,3,5];
num2=[2,4,6];
num3=[7,8,9];
nums=num1.concat(num2,num3)
trace(nums);
// creates array [1,3,5,2,4,6,7,8,9]

Array.join : Joins all elements of an array into a string.. Example:

a = new Array("Mon","Tue","Wed")
trace(a.join());
// returns Mon, Tue, Wed
trace(a.join(" - "));
// returns Mon - Tue - Wed
trace(a.join(" + "));
// returns Mon + Tue + Wed


http://www.consumerbag.com/

Posted in Libellés : Publié par y. elhafyani à l'adresse 6:55 AM  

0 commentaires:

 
Copyright 2005-2008 Flash RIA .