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>

 

 

posted on 2010-02-23 22:15  龙少爷  阅读(296)  评论(0编辑  收藏  举报

导航