Welcome!

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

Reply
Developer
Posts: 158
Registered: ‎01-11-2010
My Device: 9700 | 9900 | PlayBook | Dev Alpha
My Carrier: Many :)
Accepted Solution

Popup List selected index

I now have code that sucessfully populates an array for use with a popup box.

 

i am having probelms getting the correct index selected from the box, however.

 

the array being fed into the popup list is JUST strings

 

EG:

 

myarray = Time, OtherString, Stuff, A sentance, A loger example

 

 

in one function, i make the popup box with 2 buttons and an event listener:

 

 


// add buttons
p.addButton("QuizMe!");
p.addButton("Search Again");
p.addEventListener(Event.SELECT, getIDFromClicked);

 

 

The function i am using to catch the input

 

 

 

private function getIDFromClicked(e:Event){
            
       var d:PopupList = e.target as PopupList;
       //retrieve the selected index/indices
       trace("Selected Index : " + d.selectedIndex.toString() + " ");
       trace("Selected Index : " + d.selectedIndex + " ");
            
}

 

 

this will output

 

 

Selected Index : 0 
Selected Index : 0 

 

even if you select the 15th (out of 29) items on the popup.

 

 

i've been looking at several examples of how to capture the input from the selected index, and i believe my code to be working properly, but i can't seem to figure out why the index is *always* 0.

 

thoughts?

 

 

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

Re: Popup List selected index

hey dtater,

 

the selectedIndex property returns only the selected button of the pop up. to get the index of the selected array item, you need to use the selectedIndices property. so an example would be:

 

(in your event listener)

 

 

trace("Selected index: " + d.selectedIndices[0]);

 

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
Developer
Posts: 158
Registered: ‎01-11-2010
My Device: 9700 | 9900 | PlayBook | Dev Alpha
My Carrier: Many :)

Re: Popup List selected index

oh wow. 

 

you are fantastic.

 

all the documentation i poured over NEVER mentioned this.

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

Re: Popup List selected index

hey,

 

yah no worries! we've all bumped into this. the documentation for the QNX library is lacking in many ways but they are improving. if you ever get stuck though, we're here! good luck on the rest of your application!

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
Developer
Posts: 158
Registered: ‎01-11-2010
My Device: 9700 | 9900 | PlayBook | Dev Alpha
My Carrier: Many :)

Re: Popup List selected index

Thank you!

 

The first version is  almost done!  just a bit more major work, then some small bits of glue code.

 

then clean up and repackaging for submission!

 

Its a simple app, and it sure looks like somebody brand new to AS put it together, but as long as i get in before the 31st, all should be good.

 

thanks for your support!

 

 

 

- - - - - - - - - -