ComboBox中使用事件
代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCB();">
<mx:Script>
<![CDATA[
import mx.events.DropdownEvent;
private function initCB():void{
var info:Array = new Array();
info.push({label:"红", data: "red"});
info.push({label:"绿", data: "green"});
info.push({label:"蓝", data: "blue"});
_cb.dataProvider = info;
_cb.addEventListener(DropdownEvent.CLOSE, chooseCB);
}
private function chooseCB(evt:DropdownEvent):void{
var obj:Object = _cb.selectedItem;
_tip.text = "label:" + obj.label + " data:" + obj.data;
}
]]>
</mx:Script>
<mx:ComboBox x="62" y="51" id="_cb"></mx:ComboBox>
<mx:TextArea x="62" y="81" height="114" id="_tip"/>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initCB();">
<mx:Script>
<![CDATA[
import mx.events.DropdownEvent;
private function initCB():void{
var info:Array = new Array();
info.push({label:"红", data: "red"});
info.push({label:"绿", data: "green"});
info.push({label:"蓝", data: "blue"});
_cb.dataProvider = info;
_cb.addEventListener(DropdownEvent.CLOSE, chooseCB);
}
private function chooseCB(evt:DropdownEvent):void{
var obj:Object = _cb.selectedItem;
_tip.text = "label:" + obj.label + " data:" + obj.data;
}
]]>
</mx:Script>
<mx:ComboBox x="62" y="51" id="_cb"></mx:ComboBox>
<mx:TextArea x="62" y="81" height="114" id="_tip"/>
</mx:Application>