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
This is a mix of associative array with some function as arrayCollection

Any help on how to achieve this ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.


You want to put objects in an associative array?


Alternatively a multidimensional array might achieve what you want:

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

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

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.