03-10-2011 03:17 AM
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?
Solved! Go to Solution.
03-10-2011 03:21 AM
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!
03-10-2011 03:26 AM
oh wow.
you are fantastic.
all the documentation i poured over NEVER mentioned this.
03-10-2011 03:27 AM
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!
03-10-2011 11:14 AM
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!