Iterate through the key-value pairs of an object with the for..in and for each..in loops. : Dictionary « Array « Flash / Flex / ActionScript






Iterate through the key-value pairs of an object with the for..in and for each..in loops.

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var notes:Object = {t: 2, g: 14, s: 9};
        for (var name:String in notes)
        {
            trace("Notes on " + name + ": " + notes[name]);
        }

    }
  }
}

        








Related examples in the same category

1.Working with Associative Arrays
2.Using an Object as a Lookup Key with Dictionaries
3.When using delete on an item in an Array, the length property is not updated.