3 Replies Latest reply on Dec 20, 2010 9:45 PM by Jun yuan

    Any idea why this works for dataGrid but not for a list?

    Jun yuan Level 1

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:deviceservice="services.deviceservice.*">
      <fx:Script>
        <![CDATA[
         import mx.collections.ArrayCollection;
         import mx.controls.Alert;
         import mx.events.DragEvent;
         import mx.events.FlexEvent;
        
         import spark.events.IndexChangeEvent;
        
         //[Bindable]public var totalPrice:int =0;
       
        
         private function initApp():void {
          firstList.dataProvider = new ArrayCollection([
           {label:"First", data:"1",value:"first"},
           {label:"Second", data:"2",value:"second"},
           {label:"Third", data:"3",value:"third"},
           {label:"Fourth", data:"4",value:"fourth"}
          ]);
          secondList.dataProvider = new ArrayCollection([]);

         }

        

        


         protected function initbut_clickHandler(event:MouseEvent):void
         {
          initApp();
         }


         protected function popupbut_clickHandler(event:MouseEvent):void
         {
          //totalPrice+=int( secondList.selectedItem.data);
         
          //Alert.show(" The total price is:"+totalPrice );
         }


        


        

       


         protected function secondList_dragDropHandler(event:DragEvent):void
         {
         
         
          var artistList:String="";

        var dragObj:Array=
           event.dragSource.dataForFormat("items") as Array
      ;
         
          trace (dragObj[0].value);
         
         
          artistList="Data: " + dragObj[0].value;
          Alert.show(""+artistList);               
         }


        

        

         protected function firstList_creationCompleteHandler(event:FlexEvent):void
         {
          initApp();
         }

        ]]>
      </fx:Script>
        
      <s:List x="73" y="106" width="125" id="firstList"  dragEnabled="true"
          dragMoveEnabled="true" dropEnabled="true"  allowMultipleSelection="true" creationComplete="firstList_creationCompleteHandler(event)" ></s:List>
      <s:List x="409" y="106" width="162" id="secondList"
         dropEnabled="true" dragEnabled="true"
         dragMoveEnabled="true"
       
          dragDrop="secondList_dragDropHandler(event)" ></s:List>
      <s:Button x="187" y="245" label="Init app" id="initbut" click="initbut_clickHandler(event)"/>
      <mx:PopUpButton x="359" y="266" label="PopUpButton" id="popupbut"  click="popupbut_clickHandler(event)"/>
      <s:Label x="631" y="165" text="Label" height="17" id="show1"/>

      </s:Application>