flex as3 associative array question

I am trying to do soemthing like

var roomName:String = "room1" ; // room name
var user:User = new User("john","male"'); // new user John, male
room[roomName].addObject(user); // add his to the room

But I do not know if this is possible to obtain that in AS3
room[roomName].addObject(user);
This is a mix of associative array with some function as arrayCollection

Any help on how to achieve this ?
yarekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evcrCommented:

You want to put objects in an associative array?

http://livedocs.adobe.com/flex/3/html/10_Lists_of_data_4.html#119542

Alternatively a multidimensional array might achieve what you want:
http://livedocs.adobe.com/flex/3/html/10_Lists_of_data_5.html#119820

0
madhupanisettyCommented:
use push instead of addObject
Also create an array before using push
var room:Array = new Array;
var roomName:String = "room1" ; // room name
room[roomName] = new Array;
var Ouser1:user = new user("madhu",24); //user1
var Ouser2:user = new user("john",26); //user2
room[roomName].push (Ouser1);
room[roomName].push (Ouser2);
	
trace("[room]"+ room[roomName]);

Open in new window

0
yyyannagCommented:
You can always use Dictionary to act as associative arrays.


var dict:Dictionary = new Dictionary;
var roomName:String = "room1";
var user1:user = new user("madhu",24);
dict[roomName] = user1;
 
trace("room: " + dict[roomName]);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.