This content has been marked as final.
Show 3 replies
-
1. Re: how to drag object in a circular path?
kglad Dec 28, 2010 12:52 PM (in response to polatkanfatih)not really but you can fake it by using a loop to update the object's x,y properites and simulate a circular drag path.
-
2. Re: how to drag object in a circular path?
Andrei1 Dec 28, 2010 1:25 PM (in response to polatkanfatih)This code restrict arrow movement to a circle only (like a dial). It can be adjusted to establish boundaries within circle:
var dial:Sprite; var dialRadius = 100; var arrow:Sprite; var angleConvert:Number = 180 * angle / Math.PI; init(); function init():void { dial = new Sprite(); dial.x = dial.y = 150; var g:Graphics = dial.graphics; g.lineStyle(1, 0x004000); g.drawCircle(0, 0, dialRadius); addChild(dial); arrow = new Sprite(); arrow.buttonMode = arrow.useHandCursor = true; g = arrow.graphics; g.beginFill(0x000080); g.moveTo(0, -15); g.lineTo(7, 6); g.lineTo( -7, 6); g.endFill(); arrow.y = -dialRadius; dial.addChild(arrow); arrow.addEventListener(MouseEvent.MOUSE_DOWN, onArrowDown); } function onMove(e:MouseEvent):void { var angle:Number = Math.atan2(mouseY - dial.y, mouseX - dial.x); arrow.x = dialRadius * Math.cos(angle); arrow.y = dialRadius * Math.sin(angle); arrow.rotation = angleConvert * angle + 90; } function onArrowDown(e:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); stage.addEventListener(MouseEvent.MOUSE_UP, onArrowUp); } function onArrowUp(e:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMove); stage.removeEventListener(MouseEvent.MOUSE_UP, onArrowUp); } -
3. Re: how to drag object in a circular path?
polatkanfatih Dec 28, 2010 1:29 PM (in response to Andrei1)i will try it...
thanks...



