waysun一路阳光

不轻易服输,不轻言放弃.--心是梦的舞台,心有多大,舞台有多大。踏踏实实做事,认认真真做人。

  BlogJava :: 首页 :: 新随笔 :: 联系 ::  :: 管理 ::
  167 随笔 :: 1 文章 :: 64 评论 :: 0 Trackbacks

效果图如下:
效果图
代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="450" height="350" creationComplete="initApp()" backgroundColor="#FFFFFF" fontSize="12">
<mx:Script>
  <![CDATA[
   import mx.events.ScrollEvent;
     import mx.rpc.events.FaultEvent;  
     import mx.rpc.events.ResultEvent;
     import mx.controls.Alert;
     import mx.collections.ArrayCollection; 
     private function initApp():void{
      left.dataProvider=['广东','广西','内蒙古','北京','上海','江苏','江西','湖南','湖北','四川','西藏','新疆'];
      right.dataProvider=[];
    }
    private function toRight():void
    {
     var selectItems:Array = left.selectedItems;
     var selectIndexs:Array = left.selectedIndices;
        Alert.show(selectItems.toString()+"---"+left.selectedIndices.toString());
        if(right.dataProvider == null) 
        { 
             right.dataProvider = new ArrayCollection(); 
        } 
        for( var i:Number = 0 ; i < selectItems.length ; i++ )
        {
              ArrayCollection(right.dataProvider).addItem(selectItems[i].toString()); 
              ArrayCollection(left.dataProvider).removeItemAt(selectIndexs[i]);
        }
        
      
    }
    private function toLeft():void
    {
     var selectItems:Array = right.selectedItems;
     var selectIndexs:Array = right.selectedIndices;
        //Alert.show(selectItems.toString()+"---"+left.selectedIndices.toString());
        if(left.dataProvider == null) 
        { 
             left.dataProvider = new ArrayCollection(); 
        } 
        for( var i:Number = 0 ; i < selectItems.length ; i++ )
        {
              ArrayCollection(left.dataProvider).addItem(selectItems[i].toString()); 
              ArrayCollection(right.dataProvider).removeItemAt(selectIndexs[i]);
        }
    }
 
  ]]>
</mx:Script>
  <mx:Panel x="0" y="0" width="450" height="350" layout="absolute" title="左右互选">
    <mx:Label x="7" y="3" text="当前内容"/>
    <mx:List x="7" y="25" id="left" width="168" height="275" allowMultipleSelection="true"
          dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" doubleClickEnabled="true" itemDoubleClick="toRight()">
    </mx:List>
    <mx:Label x="243" y="3" text="移动内容"/>
    <mx:List x="243" y="25" id="right" width="180" height="272" allowMultipleSelection="true"
          dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" doubleClickEnabled="true" itemDoubleClick="toLeft()">
    </mx:List>
    <mx:Button x="183" y="121" label="-&gt;&gt;" click="toRight()" id="bt_r"/>
    <mx:Button x="183" y="178" label="&lt;&lt;-" click="toLeft()" id="bt_l"/>
  </mx:Panel>
</mx:Application>

 



 

 

  • 大小: 18.8 KB
posted on 2009-09-11 11:26 weesun一米阳光 阅读(1767) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: