/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
addEventListener(MouseEvent.CLICK, fOnEvent, false, 0, true); addEventListener(MouseEvent.MOUSE_DOWN, fOnEvent, false, 0, true); stage.addEventListener(MouseEvent.MOUSE_UP, fOnEvent, false, 0, true); function fOnEvent(e : *) : void { var vAngle : Number; switch (e.type) { case MouseEvent.MOUSE_DOWN: switch (e.target.name) { case "pbGrip": stage.addEventListener(MouseEvent.MOUSE_MOVE, fOnEvent, false, 0, true); break; } break; case MouseEvent.MOUSE_UP: stage.removeEventListener(MouseEvent.MOUSE_MOVE, fOnEvent); break; case MouseEvent.MOUSE_MOVE: vAngle = Math.atan2(mouseY - mcHandle.y, mouseX - mcHandle.x); mcHandle.rotation = vAngle * 180 / Math.PI; e.updateAfterEvent(); break; } }