如何在DropDownList中找到选择的项目?

时间:2013-05-15 11:20:13

标签: actionscript-3 flex

这是资源声明:

public var langs:ArrayCollection = new ArrayCollection(
        [ {lab:"English"},
        {lab:"Russian"}]);

这是下拉列表的声明:

<s:DropDownList x="157.7" y="10.35" id="list" ></s:DropDownList>
<s:TextArea x="15" y="38" width="255" height="277" id="textG"/>
<s:TextArea x="286" y="39" width="251" height="276" id="textT"/>
<s:Button x="465" y="322.65" label="Translate" click="button1_clickHandler(event)"/>
<s:DropDownList x="286.3" y="10.35" dataProvider="{langs}" labelField="lab" prompt="select"></s:DropDownList>

如何通过AS3查找在DropDown列表中选择的项目?

1 个答案:

答案 0 :(得分:3)

您可以为DropDownList提供ID。

<s:DropDownList id="dropDownlistID" x="286.3" y="10.35" dataProvider="{langs}" 
                labelField="lab" prompt="select"></s:DropDownList>

并将所选项目设为

dropDownlistID.selectedItem 

我不确定,但是如果您遵循API,则必须有一个名为selectedIndex的属性。因此,您可以从dataproviderArrayCollection lang获取该项目 lang.getItemAt(dropDownlistID.selectedIndex);

相关问题