backgroundColor="white">
import mx.core.DragSource;
import mx.managers.DragManager;
import mx.events.*;
import mx.controls.Button;
import mx.collections.ArrayCollection;
[Bindable]
public var myAC:ArrayCollection = new ArrayCollection([
{name:"A", price:1.5},
{name:"B", price:1.8}]);
public function initiateDrag(event:MouseEvent):void
{
var dragInitiator:Button=Button(event.currentTarget);
var ds:DragSource = new DragSource();
ds.addData(dragInitiator.label,"name");
DragManager.doDrag(dragInitiator, ds, event);
}
public function handleDragEnter(event:DragEvent):void
{
DragManager.acceptDragDrop(event.currentTarget as VBox);
}
public function handleDragOver(event:DragEvent):void
{
if (event.ctrlKey)
{
DragManager.showFeedback(DragManager.COPY);
event.currentTarget.setStyle('borderColor', 'blue');
}
}
public function handleDrop(event:DragEvent):void
{
var newButton:Button = new Button();
newButton.label = event.dragSource.dataForFormat("name") as String;
droppableArea.addChild(newButton);
droppableArea.setStyle('borderColor','black');
if(event.action == DragManager.MOVE)
buttonPanel.removeChild(event.dragInitiator as Button);
}
public function handleDragExit(event:DragEvent):void
{
droppableArea.setStyle('borderColor','black');
}
borderColor="black"
dragEnter="handleDragEnter(event)"
dragOver="handleDragOver(event)"
dragDrop="handleDrop(event)"
dragExit="handleDragExit(event)"
width="94"
height="76"
backgroundColor="#D7FE2E"
borderStyle="solid" />