Solved

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

Posted on 2013-05-10
2
449 Views
Last Modified: 2013-05-11
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
0
Comment
Question by:JoachimPetersen
2 Comments
 
LVL 19

Accepted Solution

by:
Gary Benade earned 500 total points
ID: 39155692
var users:Array = new Array();

// technique 1
var user:Object = new Object();
user.Username = 'hest';
user.ID = 12873127389;
users.push( user );

// technique 2
users.push( { Username:'john', ID:71283723 } );
users.push( { Username:'Niel', ID:2311232312 } );

for each( var user:Object in users)
{
	trace( 'Username:' + user.Username + " ID:" + user.ID);
}

Open in new window

0
 
LVL 29

Expert Comment

by:dgofman
ID: 39155870
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]);
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Youtube video error 30 810
Begin mp4 video on first frame 6 179
camtasia alternative that can record 3 hours video plus audio 24 126
Actionscript in Flash 3 71
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question