Working with Arrays of Objects : Object Array « Array « Flash / Flex / ActionScript






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

        








Related examples in the same category