Associative Arrays in ActionScript 3.0

Sometimes something very simple takes hours of your time just to figure out what’s going wrong.
I was doing a XML parsing and I was trying to save a part of information in a multi-dimensional Associative  Array.

And the problem was so easy that I would never ever guess something has been changed in AS 3.0 , till I stuck in the middle and spend hours to figure out what’s the problem.
A very simplified version of the issue is like this :

var my_arr:Array=new Array();
my_arr['test']    =    'xxx';
trace(my_arr.length); // returns 0

So as you can see, none of the properties and methods of Array won’t work for associative arrays. [refering to Adobe’s help].

Again referring to the same Help document you should use object Class whenever you need something like an Associative  Array.

Hope it will help someone out.

2 thoughts on “Associative Arrays in ActionScript 3.0

  1. jegare man, akhe haddeaghal too webloget az in esma estefade nakon! webloget filter mishehaaa!!! 😀
    badbakhti ineke to be manam ino yad dadi akhe!!!

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