开发者

Dragging a bone system element in Flash

I thought I had a really simple task to do: Create an analog clock where student could set the time by moving the hours and minutes handles.

Well, the whole thing works to a point... I have created a bone system to ensure that both handles bases stay put in the center of the clock while the handles get dragged about. The problem is that I开发者_开发技巧 cannot restrict the user movement within the "reach" of each handle (or is there?) and if the mouse happens to be OUTSIDE of the dragged handle at drop point, the MOUSE_UP event does not trigger.

I have also looked for a MovieClipModified event which would work wonders in this case but I could not find it...

Is there a way to get out of this?

TIA


You can take advantage of stage mouse events like this.

handle.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
handle.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
private function onMouseDown(e:mouseEvent):void {
  stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); //if mouse is out of drag handle then this will still keep track of mouse up event
  //do the dragging
}

private function onMouseUp(e:mouseEvent):void {
  //handle mouse up for the handle
  stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜