Link to home
Create AccountLog in
Avatar of JoachimPetersen
JoachimPetersenFlag for Denmark

asked on

Flex Mobile: Create an array that holds ID and name for each user

Hello

I want to create an array(Object) that holds ID and Name of an user, after that then also how to do the for each user and grab the current Name and ID in the 'for each' statement.

How can this be done, both the population of the array and also the manegement of the 'for each' statement for it.

Data sample:
Username:ID
hest:12873127389
john:71283723
Niel:2311232312
ASKER CERTIFIED SOLUTION
Avatar of Gary Benade
Gary Benade
Flag of South Africa image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Or you can use similar to hashmap

var users:Object = new Object();
users[12873127389] = "hest";
users[71283723] = "john";
users[2311232312] = "Niel";

for (var id:String in users)
       trace( 'Username:' + users[id]+ " ID:" + id);

The advantages using HashMap you can grad user name by id

var lookupId = 2311232312;
trace( 'Username:' + users[lookupId]);