Creating a custom drag image : Image Drag Drop « Graphics « Flex






Creating a custom drag image

Creating a custom drag image
           
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.managers.DragManager;
        import mx.core.DragSource;
        
        import flash.events.MouseEvent;
        import mx.controls.Image;
        public var imgCopy:Class;
        [Embed(source='a.png')]
        public var imgDrag:Class;
        
        public function initiateDrag(event:MouseEvent):void
        {
            var dragInitiator:Button=Button(event.currentTarget);
            var ds:DragSource = new DragSource();
            var dragImage:Image = new Image();
            var xOffset:int = -2;
            var yOffset:int = -2;
            var alphaLevel:Number = 0.5;
            dragImage.source = imgDrag;
            dragImage.height=100;
            dragImage.width=100;
            DragManager.doDrag(dragInitiator, ds, event,
            dragImage,xOffset,yOffset,alphaLevel);
        }
      
    </mx:Script>
    <mx:Button label="OK" mouseMove="initiateDrag(event)" />
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Drag and drop image on Canvas with ghost imageDrag and drop image on Canvas with ghost image
2.Drag and drop image on CanvasDrag and drop image on Canvas
3.Drag to copy image between two Canvas controlsDrag to copy image between two Canvas controls
4.Drag and move an Image from one Canvas to another CanvasDrag and move an Image from one Canvas to another Canvas
5.Use Image control to load a draggable image into a Canvas container.Use Image control to load a draggable image into a Canvas container.
6.Drag and Drop Image, Copy MoveDrag and Drop Image, Copy Move