Posted by: George Christopher | August 4, 2009

HashMap in AS3 for Flex 2


I have given below some ways to create / use HashMap in Flex.

1. Custom HashMap in AS3 for Flex 2:

2. Custom HashTable:

3. Using the Object :

On the flex side you’ll get the result as an object with keys the same
as that of your server side HashMap’s.

You can look at the keys and values in the object by putting the
following code in your result event handler:

for ( var key:String in event.result )
{"key is " + key + " val is " + event.result[key]);

4. Use Associative Arrays:

5. Use Dictionary :

Use Dictionary class to create an associative array that uses objects
for keys rather than strings. This way u can store both key and value.
var d:Dictionary = new Dictionary();
var a,b:Object = new Object();
d[a] = "apple";
d[b] = "banana";
trace(d[b]); //banana


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: