Translate

Home > August 2011

August 2011

Move an Object with out DragManager

Thursday, August 11, 2011 Category : , 0

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;
 }
}

Powered by Blogger.