Adobe Flex, Adobe AIR

Saturday, April 25, 2009

Associative arrays with object keys


You can use the Dictionary class to create an associative array that uses objects for keys rather than strings. Such arrays are sometimes called dictionaries, hashes, or maps.

import flash.display.Sprite;
import flash.utils.Dictionary;
var groupMap:Dictionary = new Dictionary();

// objects to use as keys
var spr1:Sprite = new Sprite();
var spr2:Sprite = new Sprite();
var spr3:Sprite = new Sprite();

// objects to use as values
var groupA:Object = new Object();
var groupB:Object = new Object();

// Create new key-value pairs in dictionary.

groupMap[spr1] = groupA;
groupMap[spr2] = groupB;

Posted by sindhu at 10:47 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Associative arrays with object keys

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

sindhu
View my complete profile

Blog Archive

  • ►  2010 (2)
    • ►  October (2)
      • ►  Oct 13 (1)
      • ►  Oct 11 (1)
  • ▼  2009 (16)
    • ▼  April (16)
      • ►  Apr 28 (3)
      • ►  Apr 27 (4)
      • ▼  Apr 25 (9)
        • View states
        • Events
        • Associative arrays with object keys
        • how to create associative arrays that use strings ...
        • Associative arrays
        • Sort and Query/manipulate an array
        • How to remove array elements
        • How to insert array elements
        • Arrays

Followers

Awesome Inc. theme. Powered by Blogger.