flex小结11

1 advanceddatagrid中的分组grouping应用,比如:
     import mx.rpc.events.ResultEvent;
   import mx.collections.ArrayCollection;
   
   [Bindable]
   private var bookData:ArrayCollection;
   private function bookHandler(evt:ResultEvent):void
   {
    bookData=evt.result.books.stock;
    bookGroup.refresh();
   }
  ]]>
 
 
 
 
  
  
   
   
    
    
    
   

  

 

  
   
   
   
  

 

    这样的话,是按列category来分类别浏览的
2 FLEX CSS里的global选择器
   global {
 fontFamily:"Comic Sans MS"; 
 }
3 flex里的drag and drop。flex可以在datagrid,list等控件里实行drag and drop的,先看例子
  
                        private function creationCompleteHandler():void
                {

                    srclist.dataProvider = ['Reading', 'Skating', 'Movies'];       
                    destlist.dataProvider = [];
                }

        ]]>
   

   
       
           

           
                            id="srclist" width="100%" height="100"
                allowMultipleSelection="true"               
                dragEnabled="true" dragMoveEnabled="true"
            />

       

       
           

           
                            id="destlist" width="100%" height="100"
                dropEnabled="true"
            />
       
  必须要设置原始和目标控件的dragEnabled为true,dragmoveEnabled=true时,表示是把内容剪切到另外的目标控件中

,FALSE时只COPY
   允许双向拖放,通过把两个列表的dragEnabled和dropEnabled属性都设置为true。就像下边:

    id="srclist" width="100%" height="100"
    allowMultipleSelection="true"               
    dragEnabled="true"

    dropEnabled="true"
    dragMoveEnabled="true"
/>


    id="destlist" width="100%" height="100"
    allowMultipleSelection="true"               
    dragEnabled="true"

    dropEnabled="true"
    dragMoveEnabled="true"
/>

4 drag and drop在两个datagrid中的复杂点的例子
 

        layout="horizontal"
        verticalAlign="middle"
        backgroundColor="white">

   
       
       
       
       
       
       
       
       
       
       
   

   
       
                                direction="horizontal">
                                        label="dragEnabled" />
                                        label="dropEnabled" />
                                        label="dragMoveEnabled" />
           

                                direction="horizontal">
                                        label="dragEnabled" />
                                        label="dropEnabled" />
                                        label="dragMoveEnabled" />
           

       

   

   
       
                        width="100%"
                rowHeight="22"
                dataProvider="{arr}"
                dragEnabled="{dg1_dragEnabled.selected}"
                dragMoveEnabled="{dg1_dragMoveEnabled.selected}"
                dropEnabled="{dg1_dropEnabled.selected}"
                verticalScrollPolicy="on">
           
                                        headerText="Column A" />
                                        headerText="Column B" />
                                        headerText="Column C" />
           

       

       
   

   
       
                        width="100%"
                rowHeight="22"
                dataProvider="[]"
                dragEnabled="{dg2_dragEnabled.selected}"
                dragMoveEnabled="{dg2_dragMoveEnabled.selected}"
                dropEnabled="{dg2_dropEnabled.selected}"
                verticalScrollPolicy="on">
           
                                        headerText="Column A" />
                                        headerText="Column B" />
                                        headerText="Column C" />
           

       

       
   

5 一个将LABLE拖放到LIST里的编程的例子

   import mx.collections.ArrayCollection;
  import mx.core.*;
  import mx.managers.DragManager;
  import mx.events.DragEvent;
  
  
  [Bindable]
  private var targetData:ArrayCollection=new ArrayCollection();
  
  private function dragTest

(initiator:Label,myData:String,event:MouseEvent,format:String):void
  {
   
   var ds:DragSource=new DragSource();
   ds.addData(myData,format);
   DragManager.doDrag(initiator,ds,event);
  }
  private function testDragEnter(evt:DragEvent,format:String):void
  {
   DragManager.acceptDragDrop(IUIComponent(evt.target));
   
  }
  private function testDragDrop(evt:DragEvent,format:String):void
  {
   var myData:Object=new Object();
   myData=evt.dragSource.dataForFormat(format);
   listTarget.dataProvider.addItem(myData);
  }
 ]]>

 
 

dragEnter="testDragEnter(event,'stringFormat')" dragDrop="testDragDrop(event,'stringFormat')">

你可能感兴趣的:(flex小结11)