import mx.core.DragSource;
import mx.containers.Canvas;
import mx.events.DragEvent;
import mx.managers.DragManager;
private function beginDragAndDrop(event:MouseEvent):void {
var canvas:Canvas = Canvas(event.currentTarget);
var dragSource:DragSource = new DragSource( );
var color:uint = canvas.getStyle("backgroundColor");
dragSource.addData(color, "backgroundColor");
var proxy:Canvas = new Canvas( );
proxy.width = 50;
proxy.height = 50;
proxy.setStyle("backgroundColor", color);
DragManager.doDrag(canvas, dragSource, event, proxy);
}
private function dragEnterHandler(event:DragEvent):void {
var target:Canvas = Canvas(event.currentTarget);
var initiator:Canvas = Canvas(event.dragInitiator);
if(target.getStyle("backgroundColor") == initiator.getStyle("backgroundColor")) {
DragManager.acceptDragDrop(target);
}
}
private function dragDropHandler(event:DragEvent):void {
var target:Canvas = Canvas(event.currentTarget);
var initiator:Canvas = Canvas(event.dragInitiator);
if(target.getStyle("backgroundColor") == initiator.getStyle("backgroundColor")) {
vbox.removeChild(initiator);
}
}