5 Replies Latest reply on Aug 3, 2009 7:02 AM by Gregory Lafrance

    Strange Problem Drag & Drop Between Lists

    Gregory Lafrance Level 6

      In the following code, drag & drop is set to copy objects, but when more than one instance of an item exists, only the last item (highest data provider index) item can be selected. Any idea why this is happening, and how to correct this?

       

      <?xml version="1.0"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        creationComplete="init();">
        <mx:Script>
          <![CDATA[
            import mx.collections.ArrayCollection;
           
            [Bindable] private var srcAC:ArrayCollection = new ArrayCollection();
            [Bindable] private var destAC:ArrayCollection = new ArrayCollection();

            private function init():void{
              srcAC = new ArrayCollection(['Fish', 'Meat', 'Chicken']);
              destAC = new ArrayCollection();
            }     
           
            private function displayData():void{
              trace("****************************************");
              trace("menuList dataProvider:");
              for each(var srcItem:Object in srcAC){
                trace("\t" + srcItem.toString());
              }
              trace("----------------------------------------");
              trace("orderList dataProvider:");
              for each(var destItem:Object in destAC){
                trace("\t" + destItem.toString());
              }
            }
          ]]>
        </mx:Script>
        <mx:HBox>
          <mx:VBox>
            <mx:Label text="Today's Menu" fontWeight="bold" fontSize="14"/>
            <mx:List id="menuList" width="200" dataProvider="{srcAC}"
              dragEnabled="true" dropEnabled="true" dragMoveEnabled="false"
              allowMultipleSelection="true" fontSize="14"/>
          </mx:VBox>
          <mx:VBox>
            <mx:Label text="Your Order" fontWeight="bold" fontSize="14"/>
            <mx:List id="orderList" width="200" dataProvider="{destAC}"
              dragEnabled="true" dropEnabled="true" dragMoveEnabled="false"
              allowMultipleSelection="true" fontSize="14"/>
          </mx:VBox>
        </mx:HBox>
        <mx:Button id="b1" label="Reset Order" click="init();"/>
        <mx:Button label="Display Data Providers" click="displayData();"/>
      </mx:Application>