Flash / Flex / ActionScript/Array/Object Array — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:14, 26 мая 2010

Working with Arrays of Objects

 
package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var aEmployees:Array = new Array();
        aEmployees.push({employee:"A", phone:"555-1234"});
        aEmployees.push({employee:"P", phone:"555-4321"});
        aEmployees.push({employee:"C", phone:"555-5678"});
        aEmployees.push({employee:"H", phone:"555-8765"});
        for(var i:Number = 0; i < aEmployees.length; i++) {
          trace("Employee:" + aEmployees[i].employee);
          trace("Phone Number:" + aEmployees[i].phone);
        }
    }
  }
}
Employee:A
Phone Number:555-1234
Employee:P
Phone Number:555-4321
Employee:C
Phone Number:555-5678
Employee:H
Phone Number:555-8765