PDA

View Full Version : [AS3] First item in ComboBox


matt_sh
10-12-2009, 09:45 AM
Hi,

I've got a two ComboBoxes set up and when a user clicks the first one it populates the second one and then after a user selects an item from the second one it add a MovieClip to the stage.

The problem I have is that when a user clicks itemA nothing happens. The only way to get itemA to load the MC to the stage is to click another item and then go back and click itemA.

Any idea how to get around this?

Thanks



cb1.addItem({label:"Item1"});
cb1.addItem({label:"Item2"});
cb1.addItem({label:"Item3"});

cb1.addEventListener(Event.CHANGE, cb1Handler);

function cb1Handler(event:Event):void {

if (cb1.selectedItem.label == "Item1"){

cb2.addItem({label:"ItemA"});
cb2.addItem({label:"ItemB"});
cb2.addItem({label:"ItemC"});
}

heddle
10-14-2009, 09:19 PM
Couldn't you force the cb2 to show the content immediately, since the cb1 already has the focus on Item 1? I am assuming that when you select a new item from cb1, there is a "clear list" function before re-populating cb2.

cb1.selectedIndex=0;
cb2.addItem({label:"ItemA"});
cb2.addItem({label:"ItemB"});
cb2.addItem({label:"ItemC"});


cb1.addItem({label:"Item1"});
cb1.addItem({label:"Item2"});
cb1.addItem({label:"Item3"});

cb1.addEventListener(Event.CHANGE, cb1Handler);

function cb1Handler(event:Event):void {

if (cb1.selectedItem.label == "Item1"){

cb2.addItem({label:"ItemA"});
cb2.addItem({label:"ItemB"});
cb2.addItem({label:"ItemC"});
}

seraulu1
03-03-2010, 11:12 AM
Thanks for the comment!how to hypnotize someone (http://theartofcoverthypnosis.com/)