Hello and welcome. Today we shall be leaning about one concept of Flash, arrays. Arrays are used for storing groups of information.Essentially, an array is a list of items. Those items can be text, or numbers, or decimals, or anything. Arrays in Flash ( like lists) start with bit-of-info number 0.
var myChest = new Array("cup","ball","hat","gloves","pen"); for(var i=0;i<=myChest.length-1;i++){ trace(myChest[i]); } // display the strings cup, ball, hat, gloves and pen in the output window
There are a few things that are interesting about the results. Notice that Tests 2 and 3 both return a 1, but 10 is a number in Test 2 but a string value in Test 3. The reason for that is because our contains function does not do type-checking. Our == operator in the for loop doesn't differentiate between a number and a string of the same number.
This tutorial will hold a basic introduction on three main points regarding arrays: (1) the creation of arrays, (2) accessing arrays, and finally (3) modifying arrays. This tutorial does not claim to tell you everything about arrays, but it will give you the required knowledge for you to start your own exploration on arrays in ActionScript.
An Array is just a computer term for a: List. Arrays are extremely useful in Flash, and there are numerous uses for Arrays in other programs. The aim of this tutorial is to learn how to use Arrays. There are four examples in this tutorial that show you how to use Arrays in slightly different ways. This tutorial goes through all of them in detail, explaining all the ActionScript.