Macromedia Flash Professional 8 UNLEASHED [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Macromedia Flash Professional 8 UNLEASHED [Electronic resources] - نسخه متنی

David Vogeleer, Eddie Wilson, Lou Barber

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Retrieving Information from an Array


When retrieving information from an array, use the index of the array element to pull that specific piece of data, as shown here:


var my_array:Array = new Array("fName","lName","age");
trace(my_array [1]);
//output: lName

In this example, we simply call the second element in my_array, which has the index of 1 because arrays start counting at 0.

There is a way to count the number of elements within an arrayusing the length property. It is the only property that an array has. Just attach the length property to any array with a period, and it will return the length. Here's an example:


var my_array:Array = new Array("fName","lName","age","location");
trace(my_array.length);
//output: 4

TIP

Remember, the last element in any array will always be the value of array.length minus 1.

When combined with loop statements, the length property can be used to retrieve sequential information.

This example lists each element vertically in the output window, as opposed to all in one line. Place this code in the first frame of the main timeline actions of the movie:


var my_array:Array = new Array("fName","lName","age","location");
//the loop statement to cycle through the Array
for(var i:Number = 0; i < my_array.length; i++){
trace(my_array[i]);
}
//output: fName
// lName
// age
// location

This is just a simple example of how to use a loop statement and the length property.


/ 318