Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-10
2
Medium Priority
?
494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Gary Benade earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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 how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

604 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