Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

New Developer
Posts: 47
Registered: ‎10-22-2009
My Device: Not Specified
Accepted Solution

access values from an array

I am new to actionscript. I have done a lot of java programming and cant seem to figure this out.


When the user clicks an item in the list the code is going to the onClick() event. In this event i would like to get the label caption of the selected list item. How do i do this.



var arr:Array = new Array({label:"Deschuttes The Abyss"},				  {label:"John John Juniper"},{label:"Full Sail Wreck the Halls"},
{label:"Samuel Adams Winter Lager"});

var data:DataProvider = new DataProvider(arr);			
var list:List = new List();
list.dataProvider = data;
list.containment = Containment.BACKGROUND;	

 Any help is appreciated


Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: access values from an array

hey shethab,


when you listen for the event on a list item here's what you do with your function (onClick):



public function onClick(e:ListEvent):void
	trace("labels of the clicked item: " + e.data.label);



the great things about this listener function is that using the variable e you can retrieve a ton of things (well not a ton but more than just one hah). here is a listing of the available items:



e.type:String — The type of the event.

e.data:Object — The data for the item in the list.

e.index:int — The index of the item in the list.

e.row:int — The row of the item in the list.

e.column:int — The column of the item in list.

e.section:int (default = 0) — The section of the item in the list. 


the data object in particular is the data object you clicked on passed into the list event. so you can access information such as the label property. hope that helps. good luck!


J. Rab (Blog) (Twitter)
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
New Developer
Posts: 47
Registered: ‎10-22-2009
My Device: Not Specified

Re: access values from an array

Thanks JRab that did the trick!