A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Dec 2002
    Location
    Kansas City, MO. USA
    Posts
    119

    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>
    Last edited by cmbarsotti; 03-12-2003 at 05:03 PM.
    Michael [the idiot] Barsotti

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Location
    Kansas City, MO. USA
    Posts
    119
    Does anyone ever use these componants ?
    Last edited by cmbarsotti; 03-13-2003 at 09:35 AM.
    Michael [the idiot] Barsotti

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts




Click Here to Expand Forum to Full Width


HTML5 Development Center