0

这是资源的声明:

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

这是 dorpdownlist 的声明:

<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 查找在 DropDownList 上选择了哪个项目?

4

1 回答 1

3

You can provide an id to the DropDownList.

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

and get the selected item as 

dropDownlistID.selectedItem 

I'm not sure, but if you follow the API then there must be a property called selectedIndex. So you can get the item from the dataprovider, ArrayCollection lang as lang.getItemAt(dropDownlistID.selectedIndex);

于 2013-05-15T11:21:48.127 回答