How to add two items to comboBox data field
I'm using the comboBox component in Flash MX. I build an array of the contents which consists of a label, units and value and use mcComboBox.setDataProvider(_root.comboArray) to fill the box. When a user selects an item it is added to a list so it is also removed from the comboBox via mcComboBox.removeItemAt(mcComboBox.getSelectedInde x());
The problem is a user can delete an item from the list, meaning I need to add it back into the comboBox. Using a new Object myItem to build the item to add the label, units and value I can only get the label back into the comboBox, How do I set the comboBox data to be the units and value?
Any suggestions would be appreciated. After re-reading this I don't think I stated my problem very clearly, but let's let the questions fly, ok?
relevant Code:
<pre>
arrayNonpest = new Array();
arrayNonpest = [
[ "--Select an item--","",0],
[ "26GT®","(2 x 2.5 gal/case)",450],
[ "Acclaim® Extra","(4 x 1 gal/case)",1350]
]
comboArray = new Array();
for (i = 0; i < arrayNonpest.length; i++) {
// create a real item
var myItem = new Object();
myItem.label = arrayNonpest[i][0];
myItem.unit = arrayNonpest[i][1];
myItem.value = arrayNonpest[i][2];
// put it in the array
comboArray[i] = myItem;
}
mcComboBox.onLoad = function() {
mcComboBox.setDataProvider(_root.comboArray);
};
.
.
.
//checkBox changeHandler:
function checkHandler(component) {
a = component._name;//actually this is the position number
var myItem = new Object();
myItem.label = eval("mcItem" + a).itemName.text;
myItem.unit = eval("mcItem" + a).itemUnit.text;
myItem.value = eval("mcItem" + a).itemValue.text;
mcComboBox.addItem(myItem.label);
//mcComboBox.sortItemsBy("label","ASC");
}
</pre>