views:

23

answers:

1

Hi all,

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

+3  A: 

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);
}
bhups
Works like a charm, thx a bundle... Cannot vote you up yet but I would have!
Michel Lemieux