0
votes

Hey everyone.. I'm really new to flash. I have a combo box and I am using the 'selectedIndex' property to give it a default value (a value that is at the first(0) index). Setting this property in my ActionScript does select the value in the dropdown but it does not add the selected value to the combo box's text area. How do you do this? Any selection I make has no affect on the text area.

Here is a sample of my code. The combo box list is populated fine. And the value is selected IN THE LIST. However, once you select a value in the list the combo box's list closes and nothing resides in the combo box's text field.

    comboBoxData.insert(0, {data:1, label:"Show me something specific"});
        for (i in animations) {

            comboBoxData.push({data: i.uri ,label: "somevalue"});
            }               
        comboBox.dataProvider = comboBoxData;
        comboBox.selectedIndex = 0;
        comboBox.text = comboBox.selectedIndex;

        this._lockroot = true;

My solution is using AS 2.

Thanks!

-Nick

2

2 Answers

2
votes

i think you need to add some code. i don't really understand. do you have a text area and a combobox? if that's the case then you could do something like this to give the selectedIndex to the text area

combo_cmb.selectedIndex=1;
text_txt.text=c.selectedIndex;
var listenerObjectPM:Object = new Object();
listenerObjectPM.change = function(eventObject:Object) {

        text_txt.text=combo_cmb.selectedIndex;

}
combo_cmb.addEventListener("change", listenerObjectPM);

if you want to print in the text area the label you can change the value of text_txt.text=combo_cmd.selectedItem.label; or if you want to print the data change it to text_txt.text=combo_cmb.selectedItem.data;. if this is not the case you can write the code so i can better understand what you are trying to do.

0
votes

It should be default behaviour as you stated but I had the same issue and this fixed it for me on the selection change event handler.

e.target.textField.text = e.target.selectedItem.label;