mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-30 03:05:39 -05:00
Bugfix for mouse/finger release out of stage
This commit is contained in:
parent
47f2f848e4
commit
ad767a4937
3 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
package org.gestouch.core
|
||||
{
|
||||
import flash.events.EventPhase;
|
||||
import org.gestouch.events.MouseTouchEvent;
|
||||
import org.gestouch.gestures.Gesture;
|
||||
|
||||
|
@ -198,11 +199,13 @@ package org.gestouch.core
|
|||
{
|
||||
_stage.addEventListener(TouchEvent.TOUCH_MOVE, touchMoveHandler, true);
|
||||
_stage.addEventListener(TouchEvent.TOUCH_END, touchEndHandler, true);
|
||||
_stage.addEventListener(TouchEvent.TOUCH_END, touchEndHandler);//to catch event out of stage
|
||||
}
|
||||
else
|
||||
{
|
||||
_stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, true);
|
||||
_stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);
|
||||
_stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);//to catch event out of stage
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,6 +379,10 @@ package org.gestouch.core
|
|||
|
||||
protected function touchEndHandler(event:TouchEvent):void
|
||||
{
|
||||
if (event.eventPhase == EventPhase.BUBBLING_PHASE)
|
||||
return;
|
||||
|
||||
|
||||
if (_dirtyGesturesLength > 0)
|
||||
{
|
||||
resetDirtyGestures();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gestouch.core
|
||||
{
|
||||
import flash.events.EventPhase;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.display.Stage;
|
||||
import flash.events.MouseEvent;
|
||||
|
@ -74,12 +75,16 @@ package org.gestouch.core
|
|||
stage.addEventListener(TouchEvent.TOUCH_BEGIN, stage_touchBeginHandler, true, int.MAX_VALUE);
|
||||
stage.addEventListener(TouchEvent.TOUCH_MOVE, stage_touchMoveHandler, true, int.MAX_VALUE);
|
||||
stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEndHandler, true, int.MAX_VALUE);
|
||||
// if mouse/finger leaves the stage we will get only AT_TARGET phase
|
||||
stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEndHandler, false, int.MAX_VALUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
stage.addEventListener(MouseEvent.MOUSE_DOWN, stage_mouseDownHandler, true, int.MAX_VALUE);
|
||||
stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mouseMoveHandler, true, int.MAX_VALUE);
|
||||
stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler, true, int.MAX_VALUE);
|
||||
// if mouse/finger leaves the stage we will get only AT_TARGET phase
|
||||
stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseUpHandler, false, int.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,6 +192,9 @@ package org.gestouch.core
|
|||
|
||||
protected function stage_mouseUpHandler(event:MouseEvent):void
|
||||
{
|
||||
if (event.eventPhase == EventPhase.BUBBLING_PHASE)
|
||||
return;
|
||||
|
||||
var touch:Touch = _touchesMap[0] as Touch;
|
||||
if (!touch)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,12 @@ package org.gestouch.events
|
|||
}
|
||||
|
||||
|
||||
override public function get eventPhase():uint
|
||||
{
|
||||
return _mouseEvent.eventPhase;
|
||||
}
|
||||
|
||||
|
||||
override public function get stageX():Number
|
||||
{
|
||||
return _mouseEvent.stageX;
|
||||
|
|
Loading…
Reference in a new issue