nix
nix

Reputation: 2285

How to find which item is selected on DropDownList?

This is the declaration of resource:

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

This is declaration of 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>

How to find which item is selected on DropDownList via AS3?

Upvotes: 0

Views: 516

Answers (1)

AllTooSir
AllTooSir

Reputation: 49352

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);

Upvotes: 3

Related Questions