简体   繁体   English

Flash Combo Box…将文本字段设置为选定值?

[英]Flash Combo Box… set the text field to selected value?

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). 我有一个组合框,正在使用“ selectedIndex”属性为其提供默认值(该值位于first(0)索引处)。 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. 在我的ActionScript中设置此属性的确会在下拉列表中选择值,但不会将所选值添加到组合框的文本区域。 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. 我的解决方案是使用AS 2。

Thanks! 谢谢!

-Nick -缺口

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 如果是这种情况,那么您可以执行类似的操作以将selectedIndex赋予文本区域

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; 如果要在文本区域中打印标签,则可以更改text_txt.text=combo_cmd.selectedItem.label;的值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; 或者,如果要打印数据, text_txt.text=combo_cmb.selectedItem.data;其更改为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. 如果不是这种情况,则可以编写代码,以便我可以更好地了解您要执行的操作。

它应该是您所说的默认行为,但是我遇到了同样的问题,这对我来说在选择更改事件处理程序上已得到解决。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM