Flex Gumbo中如何通过监听selectionChanged事件检测DropDownList被选择项目的例子
By Minidxer | August 9, 2009
接下来的Flex Gumbo中如何通过监听selectionChanged事件,检测DropDownList被选择项目。
下面是main.mxml:
- <?xml version="1.0"?>
- <s:Application name="Spark_DropDownList_selectionChanged_test"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/halo">
- <fx:Script>
- <![CDATA[
- import mx.events.IndexChangedEvent;
- private function dropDownList_selectionChanged(evt:IndexChangedEvent):void {
- lbl.text = dropDownList.selectedItem.team;
- }
- ]]>
- </fx:Script>
- <fx:Declarations>
- <s:ArrayList id="arrList">
- <fx:Object team="Los Angeles" name="Angels of Anaheim" />
- <fx:Object team="Seattle" name="Mariners" />
- <fx:Object team="Oakland" name="Athletics" />
- <fx:Object team="Texas" name="Rangers" />
- <fx:Object team="Cleveland" name="Indians" />
- <fx:Object team="Detroit" name="Tigers" />
- <fx:Object team="Minnesota" name="Twins" />
- <fx:Object team="Chicago" name="White Sox" />
- <fx:Object team="Kansas City" name="Royals" />
- <fx:Object team="Boston" name="Red Sox" />
- <fx:Object team="New York" name="Yankees" />
- <fx:Object team="Toronto" name="Blue Jays" />
- <fx:Object team="Baltimore" name="Orioles" />
- <fx:Object team="Tampa Bay" name="Rays" />
- <fx:Object team="Arizona" name="Diamondbacks" />
- <fx:Object team="Colorado" name="Rockies" />
- <fx:Object team="San Diego" name="Padres" />
- <fx:Object team="Los Angeles" name="Dodgers" />
- <fx:Object team="San Francisco" name="Giants" />
- <fx:Object team="Chicago" name="Cubs" />
- <fx:Object team="Milwaukee" name="Brewers" />
- <fx:Object team="St. Louis" name="Cardinals" />
- <fx:Object team="Houston" name="Astros" />
- <fx:Object team="Cincinnati" name="Reds" />
- <fx:Object team="Pittsburgh" name="Pirates" />
- <fx:Object team="Philadelphia" name="Phillies" />
- <fx:Object team="New York" name="Mets" />
- <fx:Object team="Atlanta" name="Braves" />
- <fx:Object team="Washington" name="Nationals" />
- <fx:Object team="Florida" name="Marlins" />
- </s:ArrayList>
- </fx:Declarations>
- <s:VGroup horizontalCenter="0" top="10">
- <s:DropDownList id="dropDownList"
- dataProvider="{arrList}"
- labelField="team"
- prompt="Please select a team..."
- selectionChanged="dropDownList_selectionChanged(event);" />
- <s:SimpleText id="lbl" />
- </s:VGroup>
- </s:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
DropDownList, Gumbo |
No Comments » |
Tags: Gumbo, selectionChanged