Thanks Steven, I never really understood what a dictionary was myself, so 
dictionary would be useful for something like this ?

dictionary = new Dictionary();
button1 = new Button()
dictionary[button1] = "http://www.google.com";;
button2 = new Button()
dictionary[button2] = "http://www.yahoo.com";;

function onButtonClick(event:MouseEvent){
trace(dictionary[event.target]);
}


BLITZ | Patrick Matte - 310-551-0200 x214

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks
Sent: Tuesday, March 11, 2008 12:14 PM
To: Flash Coders List
Subject: Re: [Flashcoders] dictionary vs array

An Array is a linear collection.  A Hash is a random access collection
(lookup table) of name-value pairs.

Dictionary is a fancy Hash that can take an Object as a key, instead of
a String, and uses strict (===) equality for its lookups.

hash = new Object();
hash.foo = "bar";

array = new Array();
array.push("hello");
array.push("world");

dictionary = new Dictionary();
dictionary[hash] = array;

trace(hash.foo);
-- bar

trace(array)
-- hello, world

trace(dictionary[hash]);
-- hello, world




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to