Monday, October 6, 2008

Look it up! The AS3 Dictionary Class

We are all familiar with the versatility of Arrays. Now, with AS3 comes a new addition of total awesomeness to these key- value methods of storing and retrieving information. All hail the Dictionary Class!

Like Arrays, the Dictionary Class associates values with a key. However, unlike Arrays, Dictionary keys do not have to be numeric indexes, they can be any object opening a wide array (pardon the pun) of unique opportunities.


For reference, here is the basic syntax:
import flash.utils.Dictionary;
var obj:Object = new Object();
var myDictionary:Dictionary = new Dictionary();
myDictionary[obj] = 'This is the value of the Dictionary key obj';

trace (myDictionary[obj]);


Check out Grant Skinner’s blog, for a general overview of the Class.

No comments: