PDA

View Full Version : [AS3] Help with ComboBox DropDown


ka08
10-27-2009, 04:57 PM
Can someone help me figure out the coding to my combobox problem please?

Basically, I have three comboboxes with different drop-down menus. When one item is selected on “myCombobox2”, I want another item on ”myCombobox3”. Below is some of my current code for the project.


myCombobox2.dropdown.setRendererStyle("textFormat", myTextFormat);
myCombobox2.textField.setStyle("textFormat", myTextFormat);
myCombobox2.dropdown.rowHeight = 30;
myCombobox2.prompt = "Select";
myCombobox2.addItem({label:"Green", text:"green"})
myCombobox2.addItem({label:"Blue", text:"blue"})
myCombobox2.addItem({label:"Purple", text:"purple"})
myCombobox2.addItem({label:"Red", text:"red"})


myCombobox3.dropdown.setRendererStyle("textFormat", myTextFormat);
myCombobox3.textField.setStyle("textFormat", myTextFormat);
myCombobox3.dropdown.rowHeight = 30;
myCombobox3.prompt = "Select";
myCombobox3.addItem({label:"Sweatshirt", text:"sweatshirt"})
myCombobox3.addItem({label:"T-shirt", text:"t-shirt"})
myCombobox3.addItem({label:"Pants", text:"pants"})
myCombobox3.addItem({label:"Shoes", text:"shoes"})
myCombobox3.addItem({label:"Sweater", text:"Sweater"})

How do I create code that says when “Green” has been selected, delete the “Sweater” option from “myCombobox3.” I also need “Sweater” to disappear when “Purple” has been selected.

Any help would be greatly appreciated.

Thanks!

team_chuck
10-27-2009, 05:05 PM
You could have multiple arrays containing the colours and every time someone selects a different item you could update the colours with the correct array.

For example, if 'sweater' is selected...

import fl.data.DataProvider;
myCombobox3.addEventListener(Event.CHANGE,selectio nMade);
function selectionMade(e:Event):void {
myCombobox2.dataProvider=new DataProvider(e.currentTarget.selectedIndex);
}