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