Hi,
I have several arrays that I am using to populate a listbox, the array to be used is dependent on user selection from a comboBox.
I am trying to figure out how to flexibly change the array used to populate the listbox using a variable, when a different comboBox selection is made.
All possible arrays have the same names as possible values from the combobox, so that if ‘list1’ was selected from combobox, this would call the array named ‘list1.’ I need to figure out a way to use the selectedArray variable in the for loop to populate the listbox correctly. (see bolded in code)
[AS]
var selectedArray = evt.target.getValue(); //selected array from comboBox selection.
trace("current list contents: " + _global.listcontent);
_root.listbox.removeAll();//clears listbox of previous content
for(var i = 0; i < selectedArray.length; i++){
var item = new Object();
item.label = i + " - " + **selectedArray***;
item.data = i;
_root.listbox.addItem(item.label, item.label);
}
[/AS]
What I have there is not working, no array is called, but I’m not sure how to make the variable selectedArray reference a specific array simply by name…
I hope I am explaining what I am trying to do well enough. Any help would be greatly appreciated!
Thanks=]