9 Replies Latest reply on May 23, 2010 10:43 AM by jimmyoneshot

    Setting Dragged Tilelist Item As Drag Proxy

    jimmyoneshot Level 1

      I've wrote about this problem before but I've never really elaborated on my code. I have a tilelist with an item renderer in it which has it's icons and labels poulated via an array collection retrieved via http request to an online xml file.

       

      I want it so that as each item is dragged out of the tilelist the drag proxy (the image that shows what's being dragged) is actually of the tilelist item being dragged. I'm trying to get this working in a dragInitiate function but can't seem to get it to work, Can anyone help me out please.

       

      Here's the code for my tilelist:-

       

       

      <mx:TileList id="linkChoice" mouseDown="initiateDrag(event);" dataProvider="{linksFullAC}" doubleClickEnabled="true" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" height="412" width="100%" columnCount="3" rowHeight="145" columnWidth="125" backgroundColor="#2B2B2B" borderColor="#000000" color="#FFFFFF" borderStyle="solid" borderThickness="1" verticalScrollPolicy="on" verticalScrollBarStyleName="ScrollBar" cornerRadius="0" y="40" borderSides="bottom top">
       <mx:itemRenderer>
        <mx:Component>
         <mx:Canvas width="125" height="145">
          <mx:Image source="{'http://10169603.computing.student.edgehill.ac.uk/interface/interfaceimages/images/'+data.icon+'.jpg'}" scaleContent="true" scaleY="1.2" height="100" width="100" top="10" horizontalCenter="0"/>
          <mx:Label text="{data.label}" maxWidth="120" bottom="1" horizontalCenter="0" color="#FFFFFF"/>
         </mx:Canvas>    
        </mx:Component>
       </mx:itemRenderer>  
      </mx:TileList>
      

       

      And heres my function so far:-

       

       

      private function initiateDrag(event:MouseEvent):void {         
       var dragInitiator:Image = Image(event.currentTarget.icon);        
       var source:DragSource = new DragSource();       
       source.addData(data.icon,data.label);         
       var proxy:Image = new Image();       
       proxy.source = dragInitiator.source;       
       proxy.width = 50;       
       proxy.height = 50;        
       DragManager.doDrag(dragInitiator, source, event, proxy); 
      }