效果图:

Flex DropDownList with CheckBox 多选_第1张图片

两个主要类:

CheckBoxItemRenderer.mxml



    
        
    
    
    
        
    
    
    
        
        
    
    

DropDownListEx.mxml



    
        
    
    
    
         = new Vector.();
            
            override public function set selectedItems(value:Vector.):void{
                this._selectedItems = value;
            }
            
            override public function get selectedItems():Vector.{
                return _selectedItems;
            }
            
            override public function get prompt():String{
                
                var s:String = "";
                
                selectedItems.sort(function compare(x:Object, y:Object):Number {
                    return -(Number(y['index']) - Number(x['index']));
                });
                
                for each(var item:Object in selectedItems){
                    s += (item['name']+",");
                }
                
                if(s.length > 0){
                    return s.substr(0, s.length - 1);
                }else{
                    return super.prompt;
                }
            }
            
            protected function dropdownlist_creationCompleteHandler(event:FlexEvent):void {
                this.addEventListener("selectedItemsChange", selectedItemsChangeHandler);
            }
            
            private function selectedItemsChangeHandler(evt:Event):void{
                this.labelDisplay.text = prompt;
            }
            
            override protected function item_mouseDownHandler(event:MouseEvent):void{
                
            }
            
        ]]>
    
    
    
        
            
        
    
 
  

使用方法:

                
                    
                        
                            
                            
                            
                            
                            
                            
                            
                        
                    
                

特别说明:

index:多选项目排序索引

name:选项显示的内容

你可能感兴趣的:(Flex,CheckBox,DropDownList,Flex)