Posted by: George Christopher | August 4, 2009

HashMap in AS3 for Flex 2

Adobe-Flex-CS3-256x256

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

1. Custom HashMap in AS3 for Flex 2:

http://www.ericfeminella.com/blog/actionscript-3-apis/
http://www.ericfeminella.com/blog/2006/12/05/as3-hashmap-for-flex/

2. Custom HashTable:

http://code.google.com/p/developmentarc-core/wiki/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 )
{
   Alert.show("key is " + key + " val is " + event.result[key]);
}

4. Use Associative Arrays:
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=10_Lists_of_data_166_3.html

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Categories

%d bloggers like this: