I'm still fairly new to ActionScript but here's an example:
HoverMenuSprite
package examples.classes.starling.scenes
{
import feathers.dragDrop.IDropTarget;
import examples.classes.starling.controls.DraggableSprite;
import starling.text.TextField;
import starling.display.Sprite;
import starling.display.Quad;
import examples.classes.starling.controls.DroppableSprite;
public class HoverMenuSprite extends Sprite implements IDropTarget
{
private var _tiledColumnsScreen:TiledColumnsLayoutScreen;
public function HoverMenuSprite()
{
super();
var description:String = "Hover Menu Example";
var infoText:TextField = new TextField(125, 125, description);
infoText.fontSize = 18;
infoText.color = 0x000000;
infoText.y = 0;
infoText.x = 50;
addChild(infoText);
var droppableSprite:DroppableSprite = new DroppableSprite();
addChild(droppableSprite);
var icon:Quad = new Quad(50, 50, 65280);
var dragTexture:DraggableSprite = new DraggableSprite(icon);
dragTexture.x = 250;
dragTexture.y = 150;
addChild(dragTexture);
}
}
}
DroppableSprite
package examples.classes.starling.controls
{
import feathers.dragDrop.DragDropManager;
import feathers.dragDrop.IDropTarget;
import feathers.events.DragDropEvent;
import starling.display.Quad;
import starling.display.Sprite;
public class DroppableSprite extends Sprite implements IDropTarget
{
private var _bgQuad:Quad;
private var BG_COLOR_ACTIVE:uint = 8224125;
private var BG_COLOR_IDLE:uint = 7224125;
private var BG_COLOR_GREEN:uint = 65280;
public function DroppableSprite()
{
addEventListener(DragDropEvent.DRAG_ENTER, onDragEnter);
addEventListener(DragDropEvent.DRAG_DROP, onDragDrop);
addEventListener(DragDropEvent.DRAG_EXIT, onDragExit);
useHandCursor = true;
_bgQuad = new Quad(150, 500, BG_COLOR_IDLE);
_bgQuad.x = _bgQuad.y = 0;
addChild(_bgQuad);
}
private function onDragEnter(event:DragDropEvent):void
{
trace("onDragEnter()");
if (event.dragData.hasDataForFormat("box-drag-format"))
{
DragDropManager.acceptDrag(this);
_bgQuad.color = BG_COLOR_ACTIVE;
}
}
private function onDragDrop(event:DragDropEvent):void
{
trace("onDragDrop()");
if (event.dragData.hasDataForFormat("box-drag-format"))
{
_bgQuad.color = BG_COLOR_GREEN;
}
}
private function onDragExit(event:DragDropEvent):void
{
trace("onDragExit()");
if (!event.isDropped)
{
_bgQuad.color = BG_COLOR_IDLE;
}
}
public override function dispose():void
{
removeEventListener(DragDropEvent.DRAG_ENTER, onDragEnter);
removeEventListener(DragDropEvent.DRAG_DROP, onDragDrop);
removeEventListener(DragDropEvent.DRAG_COMPLETE, onDragExit);
super.dispose();
}
}
}
DraggableSprite
package examples.classes.starling.controls
{
import feathers.dragDrop.DragData;
import feathers.dragDrop.DragDropManager;
import feathers.dragDrop.IDragSource;
import starling.display.DisplayObject;
import starling.display.Quad;
import starling.display.Sprite;
import starling.events.Touch;
import starling.events.TouchEvent;
import starling.events.TouchPhase;
public class DraggableSprite extends Sprite implements IDragSource
{
private var _dragSource:IDragSource;
public function DraggableSprite(contents:DisplayObject=null)
{
_dragSource = this;
addEventListener(TouchEvent.TOUCH, onTouch);
useHandCursor = true;
if (contents)
{
contents.x = int(contents.width / -2);
contents.y = int(contents.height / -2);
addChild(contents);
}
}
private function onTouch(event:TouchEvent):void
{
var touch:Touch = event.getTouch(this, TouchPhase.MOVED);
if (touch)
{
var dragData:DragData = new DragData();
dragData.setDataForFormat("box-drag-format", {data: "Hello World"});
var avatar:Quad = new Quad(50, 50, 65280);
DragDropManager.startDrag(_dragSource, touch, dragData, avatar);
}
}
public override function dispose():void
{
removeEventListener(TouchEvent.TOUCH, onTouch);
super.dispose();
}
}
}
To use just create and add an HoverMenuSprite to your scene.