Solved

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

Posted on 2013-05-10
2
473 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

726 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