Move an Object with out DragManager
Posted on Thursday, August 11, 2011
|
No Comments
Ball.addEventListener(MouseEvent.MOUSE_DOWN,starDragBall);
stage.addEventListener(MouseEvent.MOUSE_UP,stopDragBall);
Ball.addEventListener(Event.ENTER_FRAME,doDrag);
var clickOffset:Point = null;
function starDragBall(event:MouseEvent)
{
clickOffset = new Point(event.localX,event.localY);
}
function stopDragBall(event:MouseEvent)
{
clickOffset = null;
}
function doDrag(event:Event)
{
if(clickOffset != null)
{
Ball.x = mouseX - clickOffset.x;
Ball.y = mouseY - clickOffset.y;
}
}