mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-23 07:47:59 -05:00
Touch properties updates (and corresponding gestures fixes)
This commit is contained in:
parent
b56107e059
commit
4d5bef0252
9 changed files with 114 additions and 133 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.gestouch.core
|
package org.gestouch.core
|
||||||
{
|
{
|
||||||
import flash.display.InteractiveObject;
|
import flash.display.InteractiveObject;
|
||||||
|
import flash.geom.Point;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,18 +21,11 @@ package org.gestouch.core
|
||||||
*/
|
*/
|
||||||
public var target:InteractiveObject;
|
public var target:InteractiveObject;
|
||||||
|
|
||||||
public var x:Number;
|
|
||||||
public var y:Number;
|
|
||||||
public var sizeX:Number;
|
public var sizeX:Number;
|
||||||
public var sizeY:Number;
|
public var sizeY:Number;
|
||||||
public var pressure:Number;
|
public var pressure:Number;
|
||||||
public var time:uint;
|
|
||||||
|
|
||||||
// public var touchBeginPos:Point;
|
|
||||||
// public var touchBeginTime:uint;
|
|
||||||
// public var moveOffset:Point;
|
|
||||||
// public var lastMove:Point;
|
// public var lastMove:Point;
|
||||||
// public var velocity:Point;
|
|
||||||
|
|
||||||
|
|
||||||
public function Touch(id:uint = 0)
|
public function Touch(id:uint = 0)
|
||||||
|
@ -40,16 +34,76 @@ package org.gestouch.core
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected var _location:Point;
|
||||||
|
public function get location():Point
|
||||||
|
{
|
||||||
|
return _location.clone();
|
||||||
|
}
|
||||||
|
gestouch_internal function setLocation(value:Point):void
|
||||||
|
{
|
||||||
|
_location = value;
|
||||||
|
_beginLocation = _location.clone();
|
||||||
|
}
|
||||||
|
gestouch_internal function updateLocation(x:Number, y:Number):void
|
||||||
|
{
|
||||||
|
if (_location)
|
||||||
|
{
|
||||||
|
_location.x = x;
|
||||||
|
_location.y = y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gestouch_internal::setLocation(new Point(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected var _beginLocation:Point;
|
||||||
|
public function get beginLocation():Point
|
||||||
|
{
|
||||||
|
return _beginLocation.clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get locationOffset():Point
|
||||||
|
{
|
||||||
|
return _location.subtract(_beginLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected var _time:uint;
|
||||||
|
public function get time():uint
|
||||||
|
{
|
||||||
|
return _time;
|
||||||
|
}
|
||||||
|
gestouch_internal function setTime(value:uint):void
|
||||||
|
{
|
||||||
|
_time = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected var _beginTime:uint;
|
||||||
|
public function get beginTime():uint
|
||||||
|
{
|
||||||
|
return _beginTime;
|
||||||
|
}
|
||||||
|
gestouch_internal function setBeginTime(value:uint):void
|
||||||
|
{
|
||||||
|
_beginTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function clone():Touch
|
public function clone():Touch
|
||||||
{
|
{
|
||||||
var touch:Touch = new Touch(id);
|
var touch:Touch = new Touch(id);
|
||||||
touch.x = x;
|
touch._location = _location;
|
||||||
touch.y = y;
|
touch._beginLocation = _beginLocation;
|
||||||
touch.target = target;
|
touch.target = target;
|
||||||
touch.sizeX = sizeX;
|
touch.sizeX = sizeX;
|
||||||
touch.sizeY = sizeY;
|
touch.sizeY = sizeY;
|
||||||
touch.pressure = pressure;
|
touch.pressure = pressure;
|
||||||
touch.time = time;
|
touch._time = _time;
|
||||||
|
touch._beginTime = _beginTime;
|
||||||
|
|
||||||
return touch;
|
return touch;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +111,7 @@ package org.gestouch.core
|
||||||
|
|
||||||
public function toString():String
|
public function toString():String
|
||||||
{
|
{
|
||||||
return "Touch [id: " + id + ", x: " + x + ", y: " + y + ", ...]";
|
return "Touch [id: " + id + ", location: " + location + ", ...]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -359,14 +359,14 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
protected function updateCentralPoint():void
|
protected function updateCentralPoint():void
|
||||||
{
|
{
|
||||||
var touch:Touch;
|
var touchLocation:Point;
|
||||||
var x:Number = 0;
|
var x:Number = 0;
|
||||||
var y:Number = 0;
|
var y:Number = 0;
|
||||||
for (var touchID:String in _touchesMap)
|
for (var touchID:String in _touchesMap)
|
||||||
{
|
{
|
||||||
touch = _touchesMap[int(touchID)] as Touch;
|
touchLocation = (_touchesMap[int(touchID)] as Touch).location;
|
||||||
x += touch.x;
|
x += touchLocation.x;
|
||||||
y += touch.y;
|
y += touchLocation.y;
|
||||||
}
|
}
|
||||||
_centralPoint.x = x / _touchesCount;
|
_centralPoint.x = x / _touchesCount;
|
||||||
_centralPoint.y = y / _touchesCount;
|
_centralPoint.y = y / _touchesCount;
|
||||||
|
|
|
@ -28,8 +28,6 @@ package org.gestouch.gestures
|
||||||
public var slop:Number = Gesture.DEFAULT_SLOP;
|
public var slop:Number = Gesture.DEFAULT_SLOP;
|
||||||
|
|
||||||
protected var _timer:Timer;
|
protected var _timer:Timer;
|
||||||
protected var _touchBeginX:Array = [];
|
|
||||||
protected var _touchBeginY:Array = [];
|
|
||||||
protected var _numTouchesRequiredReached:Boolean;
|
protected var _numTouchesRequiredReached:Boolean;
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,8 +55,6 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
super.reset();
|
super.reset();
|
||||||
|
|
||||||
_touchBeginX.length = 0;
|
|
||||||
_touchBeginY.length = 0;
|
|
||||||
_numTouchesRequiredReached = false;
|
_numTouchesRequiredReached = false;
|
||||||
_timer.reset();
|
_timer.reset();
|
||||||
}
|
}
|
||||||
|
@ -96,9 +92,6 @@ package org.gestouch.gestures
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_touchBeginX[touch.id] = touch.x;
|
|
||||||
_touchBeginY[touch.id] = touch.y;
|
|
||||||
|
|
||||||
if (touchesCount == numTouchesRequired)
|
if (touchesCount == numTouchesRequired)
|
||||||
{
|
{
|
||||||
_numTouchesRequiredReached = true;
|
_numTouchesRequiredReached = true;
|
||||||
|
@ -120,10 +113,7 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
if (state == GestureState.POSSIBLE && slop > 0)
|
if (state == GestureState.POSSIBLE && slop > 0)
|
||||||
{
|
{
|
||||||
// Fail if touch overcome slop distance
|
if (touch.locationOffset.length > slop)
|
||||||
var dx:Number = Number(_touchBeginX[touch.id]) - touch.x;
|
|
||||||
var dy:Number = Number(_touchBeginY[touch.id]) - touch.y;
|
|
||||||
if (Math.sqrt(dx*dx + dy*dy) > slop)
|
|
||||||
{
|
{
|
||||||
setState(GestureState.FAILED);
|
setState(GestureState.FAILED);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -24,9 +24,6 @@ package org.gestouch.gestures
|
||||||
*/
|
*/
|
||||||
public var direction:uint = PanGestureDirection.NO_DIRECTION;
|
public var direction:uint = PanGestureDirection.NO_DIRECTION;
|
||||||
|
|
||||||
protected var _touchBeginX:Array = [];
|
|
||||||
protected var _touchBeginY:Array = [];
|
|
||||||
|
|
||||||
|
|
||||||
public function PanGesture(target:InteractiveObject = null)
|
public function PanGesture(target:InteractiveObject = null)
|
||||||
{
|
{
|
||||||
|
@ -91,15 +88,6 @@ package org.gestouch.gestures
|
||||||
return PanGesture;
|
return PanGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override public function reset():void
|
|
||||||
{
|
|
||||||
_touchBeginX.length = 0;
|
|
||||||
_touchBeginY.length = 0;
|
|
||||||
|
|
||||||
super.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,9 +106,6 @@ package org.gestouch.gestures
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_touchBeginX[touch.id] = touch.x;
|
|
||||||
_touchBeginY[touch.id] = touch.y;
|
|
||||||
|
|
||||||
if (touchesCount >= minNumTouchesRequired)
|
if (touchesCount >= minNumTouchesRequired)
|
||||||
{
|
{
|
||||||
updateLocation();
|
updateLocation();
|
||||||
|
@ -141,9 +126,17 @@ package org.gestouch.gestures
|
||||||
if (state == GestureState.POSSIBLE)
|
if (state == GestureState.POSSIBLE)
|
||||||
{
|
{
|
||||||
// Check if finger moved enough for gesture to be recognized
|
// Check if finger moved enough for gesture to be recognized
|
||||||
var dx:Number = (direction == PanGestureDirection.VERTICAL) ? 0 : Number(_touchBeginX[touch.id]) - touch.x;
|
var locationOffset:Point = touch.locationOffset;
|
||||||
var dy:Number = (direction == PanGestureDirection.HORIZONTAL) ? 0 : Number(_touchBeginY[touch.id]) - touch.y;
|
if (direction == PanGestureDirection.VERTICAL)
|
||||||
if (Math.sqrt(dx*dx + dy*dy) > slop || slop != slop)//faster isNaN(slop)
|
{
|
||||||
|
locationOffset.x = 0;
|
||||||
|
}
|
||||||
|
else if (direction == PanGestureDirection.HORIZONTAL)
|
||||||
|
{
|
||||||
|
locationOffset.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locationOffset.length > slop || slop != slop)//faster isNaN(slop)
|
||||||
{
|
{
|
||||||
prevLocationX = _location.x;
|
prevLocationX = _location.x;
|
||||||
prevLocationY = _location.y;
|
prevLocationY = _location.y;
|
||||||
|
|
|
@ -21,8 +21,6 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
public var slop:Number = Gesture.DEFAULT_SLOP >> 1;
|
public var slop:Number = Gesture.DEFAULT_SLOP >> 1;
|
||||||
|
|
||||||
protected var _touchBeginX:Array = [];
|
|
||||||
protected var _touchBeginY:Array = [];
|
|
||||||
protected var _rotationVector:Point = new Point();
|
protected var _rotationVector:Point = new Point();
|
||||||
protected var _firstTouch:Touch;
|
protected var _firstTouch:Touch;
|
||||||
protected var _secondTouch:Touch;
|
protected var _secondTouch:Touch;
|
||||||
|
@ -47,15 +45,6 @@ package org.gestouch.gestures
|
||||||
return RotateGesture;
|
return RotateGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override public function reset():void
|
|
||||||
{
|
|
||||||
_touchBeginX.length = 0;
|
|
||||||
_touchBeginY.length = 0;
|
|
||||||
|
|
||||||
super.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,13 +71,7 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
_secondTouch = touch;
|
_secondTouch = touch;
|
||||||
|
|
||||||
_touchBeginX[_firstTouch.id] = _firstTouch.x;
|
_rotationVector = _secondTouch.location.subtract(_firstTouch.location);
|
||||||
_touchBeginY[_firstTouch.id] = _firstTouch.y;
|
|
||||||
_touchBeginX[_secondTouch.id] = _secondTouch.x;
|
|
||||||
_touchBeginY[_secondTouch.id] = _secondTouch.y;
|
|
||||||
|
|
||||||
_rotationVector.x = _secondTouch.x - _firstTouch.x;
|
|
||||||
_rotationVector.y = _secondTouch.y - _firstTouch.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,19 +89,14 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
if (touchesCount == 2)
|
if (touchesCount == 2)
|
||||||
{
|
{
|
||||||
var currRotationVector:Point = new Point(_secondTouch.x - _firstTouch.x, _secondTouch.y - _firstTouch.y);
|
|
||||||
var recognized:Boolean;
|
var recognized:Boolean;
|
||||||
|
|
||||||
if (state == GestureState.POSSIBLE)
|
if (state == GestureState.POSSIBLE)
|
||||||
{
|
{
|
||||||
// we start once any finger moved enough
|
// we start once any finger moved enough
|
||||||
var dx:Number = Number(_touchBeginX[touch.id]) - touch.x;
|
if (touch.locationOffset.length > slop || slop != slop)//faster isNaN(slop)
|
||||||
var dy:Number = Number(_touchBeginY[touch.id]) - touch.y;
|
|
||||||
if (Math.sqrt(dx*dx + dy*dy) > slop || slop != slop)//faster isNaN(slop)
|
|
||||||
{
|
{
|
||||||
recognized = true;
|
recognized = true;
|
||||||
_rotationVector.x = _secondTouch.x - _firstTouch.x;
|
|
||||||
_rotationVector.y = _secondTouch.y - _firstTouch.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -128,13 +106,14 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
if (recognized)
|
if (recognized)
|
||||||
{
|
{
|
||||||
updateLocation();
|
var currRotationVector:Point = _secondTouch.location.subtract(_firstTouch.location);
|
||||||
|
|
||||||
var rotation:Number = Math.atan2(currRotationVector.y, currRotationVector.x) - Math.atan2(_rotationVector.y, _rotationVector.x);
|
var rotation:Number = Math.atan2(currRotationVector.y, currRotationVector.x) - Math.atan2(_rotationVector.y, _rotationVector.x);
|
||||||
rotation *= GestureUtils.RADIANS_TO_DEGREES;
|
rotation *= GestureUtils.RADIANS_TO_DEGREES;
|
||||||
_rotationVector.x = currRotationVector.x;
|
_rotationVector.x = currRotationVector.x;
|
||||||
_rotationVector.y = currRotationVector.y;
|
_rotationVector.y = currRotationVector.y;
|
||||||
|
|
||||||
|
updateLocation();
|
||||||
|
|
||||||
if (state == GestureState.POSSIBLE)
|
if (state == GestureState.POSSIBLE)
|
||||||
{
|
{
|
||||||
if (setState(GestureState.BEGAN) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
|
if (setState(GestureState.BEGAN) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
|
||||||
|
|
|
@ -24,8 +24,6 @@ package org.gestouch.gestures
|
||||||
public var maxTapDuration:uint = 1500;
|
public var maxTapDuration:uint = 1500;
|
||||||
|
|
||||||
protected var _timer:Timer;
|
protected var _timer:Timer;
|
||||||
protected var _touchBeginX:Array = [];
|
|
||||||
protected var _touchBeginY:Array = [];
|
|
||||||
protected var _numTouchesRequiredReached:Boolean;
|
protected var _numTouchesRequiredReached:Boolean;
|
||||||
protected var _tapCounter:uint = 0;
|
protected var _tapCounter:uint = 0;
|
||||||
|
|
||||||
|
@ -51,9 +49,7 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
|
|
||||||
override public function reset():void
|
override public function reset():void
|
||||||
{
|
{
|
||||||
_touchBeginX.length = 0;
|
|
||||||
_touchBeginY.length = 0;
|
|
||||||
_numTouchesRequiredReached = false;
|
_numTouchesRequiredReached = false;
|
||||||
_tapCounter = 0;
|
_tapCounter = 0;
|
||||||
_timer.reset();
|
_timer.reset();
|
||||||
|
@ -100,9 +96,6 @@ package org.gestouch.gestures
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_touchBeginX[touch.id] = touch.x;
|
|
||||||
_touchBeginY[touch.id] = touch.y;
|
|
||||||
|
|
||||||
if (touchesCount == 1)
|
if (touchesCount == 1)
|
||||||
{
|
{
|
||||||
_timer.reset();
|
_timer.reset();
|
||||||
|
@ -119,15 +112,9 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
override protected function onTouchMove(touch:Touch):void
|
override protected function onTouchMove(touch:Touch):void
|
||||||
{
|
{
|
||||||
if (slop >= 0)
|
if (slop >= 0 && touch.locationOffset.length > slop)
|
||||||
{
|
{
|
||||||
// Fail if touch overcome slop distance
|
setState(GestureState.FAILED);
|
||||||
var dx:Number = Number(_touchBeginX[touch.id]) - touch.x;
|
|
||||||
var dy:Number = Number(_touchBeginY[touch.id]) - touch.y;
|
|
||||||
if (Math.sqrt(dx*dx + dy*dy) > slop)
|
|
||||||
{
|
|
||||||
setState(GestureState.FAILED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,6 @@ package org.gestouch.gestures
|
||||||
public var slop:Number = Gesture.DEFAULT_SLOP >> 1;
|
public var slop:Number = Gesture.DEFAULT_SLOP >> 1;
|
||||||
public var lockAspectRatio:Boolean = true;
|
public var lockAspectRatio:Boolean = true;
|
||||||
|
|
||||||
protected var _touchBeginX:Array = [];
|
|
||||||
protected var _touchBeginY:Array = [];
|
|
||||||
protected var _scaleVector:Point = new Point();
|
protected var _scaleVector:Point = new Point();
|
||||||
protected var _firstTouch:Touch;
|
protected var _firstTouch:Touch;
|
||||||
protected var _secondTouch:Touch;
|
protected var _secondTouch:Touch;
|
||||||
|
@ -47,15 +45,6 @@ package org.gestouch.gestures
|
||||||
return ZoomGesture;
|
return ZoomGesture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override public function reset():void
|
|
||||||
{
|
|
||||||
_touchBeginX.length = 0;
|
|
||||||
_touchBeginY.length = 0;
|
|
||||||
|
|
||||||
super.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,13 +71,7 @@ package org.gestouch.gestures
|
||||||
{
|
{
|
||||||
_secondTouch = touch;
|
_secondTouch = touch;
|
||||||
|
|
||||||
_touchBeginX[_firstTouch.id] = _firstTouch.x;
|
_scaleVector = _secondTouch.location.subtract(_firstTouch.location);
|
||||||
_touchBeginY[_firstTouch.id] = _firstTouch.y;
|
|
||||||
_touchBeginX[_secondTouch.id] = _secondTouch.x;
|
|
||||||
_touchBeginY[_secondTouch.id] = _secondTouch.y;
|
|
||||||
|
|
||||||
_scaleVector.x = _secondTouch.x - _firstTouch.x;
|
|
||||||
_scaleVector.y = _secondTouch.y - _firstTouch.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,19 +89,14 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
if (touchesCount == 2)
|
if (touchesCount == 2)
|
||||||
{
|
{
|
||||||
var currScaleVector:Point = new Point(_secondTouch.x - _firstTouch.x, _secondTouch.y - _firstTouch.y);
|
|
||||||
var recognized:Boolean;
|
var recognized:Boolean;
|
||||||
|
|
||||||
if (state == GestureState.POSSIBLE)
|
if (state == GestureState.POSSIBLE)
|
||||||
{
|
{
|
||||||
// Check if finger moved enough for gesture to be recognized
|
// Check if finger moved enough for gesture to be recognized
|
||||||
var dx:Number = Number(_touchBeginX[touch.id]) - touch.x;
|
if (touch.locationOffset.length > slop || slop != slop)//faster isNaN(slop)
|
||||||
var dy:Number = Number(_touchBeginY[touch.id]) - touch.y;
|
|
||||||
if (Math.sqrt(dx*dx + dy*dy) > slop || slop != slop)//faster isNaN(slop)
|
|
||||||
{
|
{
|
||||||
recognized = true;
|
recognized = true;
|
||||||
_scaleVector.x = _secondTouch.x - _firstTouch.x;
|
|
||||||
_scaleVector.y = _secondTouch.y - _firstTouch.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -128,8 +106,7 @@ package org.gestouch.gestures
|
||||||
|
|
||||||
if (recognized)
|
if (recognized)
|
||||||
{
|
{
|
||||||
updateLocation();
|
var currScaleVector:Point = _secondTouch.location.subtract(_firstTouch.location);
|
||||||
|
|
||||||
var scaleX:Number;
|
var scaleX:Number;
|
||||||
var scaleY:Number;
|
var scaleY:Number;
|
||||||
if (lockAspectRatio)
|
if (lockAspectRatio)
|
||||||
|
@ -145,6 +122,8 @@ package org.gestouch.gestures
|
||||||
_scaleVector.x = currScaleVector.x;
|
_scaleVector.x = currScaleVector.x;
|
||||||
_scaleVector.y = currScaleVector.y;
|
_scaleVector.y = currScaleVector.y;
|
||||||
|
|
||||||
|
updateLocation();
|
||||||
|
|
||||||
if (state == GestureState.POSSIBLE)
|
if (state == GestureState.POSSIBLE)
|
||||||
{
|
{
|
||||||
if (setState(GestureState.BEGAN) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
|
if (setState(GestureState.BEGAN) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.gestouch.input
|
||||||
import flash.display.Stage;
|
import flash.display.Stage;
|
||||||
import flash.events.EventPhase;
|
import flash.events.EventPhase;
|
||||||
import flash.events.MouseEvent;
|
import flash.events.MouseEvent;
|
||||||
|
import flash.geom.Point;
|
||||||
import flash.utils.getTimer;
|
import flash.utils.getTimer;
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,9 +79,9 @@ package org.gestouch.input
|
||||||
var touch:Touch = _touchesManager.createTouch();
|
var touch:Touch = _touchesManager.createTouch();
|
||||||
touch.id = 0;
|
touch.id = 0;
|
||||||
touch.target = event.target as InteractiveObject;
|
touch.target = event.target as InteractiveObject;
|
||||||
touch.x = event.stageX;
|
touch.gestouch_internal::setLocation(new Point(event.stageX, event.stageY));
|
||||||
touch.y = event.stageY;
|
touch.gestouch_internal::setTime(getTimer());
|
||||||
touch.time = getTimer();
|
touch.gestouch_internal::setBeginTime(getTimer());
|
||||||
|
|
||||||
_touchesManager.addTouch(touch);
|
_touchesManager.addTouch(touch);
|
||||||
|
|
||||||
|
@ -96,9 +97,8 @@ package org.gestouch.input
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var touch:Touch = _touchesManager.getTouch(PRIMARY_TOUCH_POINT_ID);
|
var touch:Touch = _touchesManager.getTouch(PRIMARY_TOUCH_POINT_ID);
|
||||||
touch.x = event.stageX;
|
touch.gestouch_internal::updateLocation(event.stageX, event.stageY);
|
||||||
touch.y = event.stageY;
|
touch.gestouch_internal::setTime(getTimer());
|
||||||
touch.time = getTimer();
|
|
||||||
|
|
||||||
_gesturesManager.gestouch_internal::onTouchMove(touch);
|
_gesturesManager.gestouch_internal::onTouchMove(touch);
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,8 @@ package org.gestouch.input
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var touch:Touch = _touchesManager.getTouch(PRIMARY_TOUCH_POINT_ID);
|
var touch:Touch = _touchesManager.getTouch(PRIMARY_TOUCH_POINT_ID);
|
||||||
touch.x = event.stageX;
|
touch.gestouch_internal::updateLocation(event.stageX, event.stageY);
|
||||||
touch.y = event.stageY;
|
touch.gestouch_internal::setTime(getTimer());
|
||||||
touch.time = getTimer();
|
|
||||||
|
|
||||||
_gesturesManager.gestouch_internal::onTouchEnd(touch);
|
_gesturesManager.gestouch_internal::onTouchEnd(touch);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.gestouch.input
|
||||||
import flash.display.Stage;
|
import flash.display.Stage;
|
||||||
import flash.events.EventPhase;
|
import flash.events.EventPhase;
|
||||||
import flash.events.TouchEvent;
|
import flash.events.TouchEvent;
|
||||||
|
import flash.geom.Point;
|
||||||
import flash.utils.getTimer;
|
import flash.utils.getTimer;
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,19 +82,20 @@ package org.gestouch.input
|
||||||
var touch:Touch = _touchesManager.createTouch();
|
var touch:Touch = _touchesManager.createTouch();
|
||||||
touch.id = event.touchPointID;
|
touch.id = event.touchPointID;
|
||||||
touch.target = event.target as InteractiveObject;
|
touch.target = event.target as InteractiveObject;
|
||||||
touch.x = event.stageX;
|
touch.gestouch_internal::setLocation(new Point(event.stageX, event.stageY));
|
||||||
touch.y = event.stageY;
|
|
||||||
touch.sizeX = event.sizeX;
|
touch.sizeX = event.sizeX;
|
||||||
touch.sizeY = event.sizeY;
|
touch.sizeY = event.sizeY;
|
||||||
touch.pressure = event.pressure;
|
touch.pressure = event.pressure;
|
||||||
//TODO: conditional compilation?
|
//TODO: conditional compilation?
|
||||||
if (event.hasOwnProperty("timestamp"))
|
if (event.hasOwnProperty("timestamp"))
|
||||||
{
|
{
|
||||||
touch.time = event["timestamp"];
|
touch.gestouch_internal::setTime(event["timestamp"]);
|
||||||
|
touch.gestouch_internal::setBeginTime(event["timestamp"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
touch.time = getTimer();
|
touch.gestouch_internal::setTime(getTimer());
|
||||||
|
touch.gestouch_internal::setBeginTime(getTimer());
|
||||||
}
|
}
|
||||||
|
|
||||||
_touchesManager.addTouch(touch);
|
_touchesManager.addTouch(touch);
|
||||||
|
@ -111,19 +113,18 @@ package org.gestouch.input
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var touch:Touch = _touchesManager.getTouch(event.touchPointID);
|
var touch:Touch = _touchesManager.getTouch(event.touchPointID);
|
||||||
touch.x = event.stageX;
|
touch.gestouch_internal::updateLocation(event.stageX, event.stageY);
|
||||||
touch.y = event.stageY;
|
|
||||||
touch.sizeX = event.sizeX;
|
touch.sizeX = event.sizeX;
|
||||||
touch.sizeY = event.sizeY;
|
touch.sizeY = event.sizeY;
|
||||||
touch.pressure = event.pressure;
|
touch.pressure = event.pressure;
|
||||||
//TODO: conditional compilation?
|
//TODO: conditional compilation?
|
||||||
if (event.hasOwnProperty("timestamp"))
|
if (event.hasOwnProperty("timestamp"))
|
||||||
{
|
{
|
||||||
touch.time = event["timestamp"];
|
touch.gestouch_internal::setTime(event["timestamp"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
touch.time = getTimer();
|
touch.gestouch_internal::setTime(getTimer());
|
||||||
}
|
}
|
||||||
|
|
||||||
_gesturesManager.gestouch_internal::onTouchMove(touch);
|
_gesturesManager.gestouch_internal::onTouchMove(touch);
|
||||||
|
@ -142,19 +143,18 @@ package org.gestouch.input
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var touch:Touch = _touchesManager.getTouch(event.touchPointID);
|
var touch:Touch = _touchesManager.getTouch(event.touchPointID);
|
||||||
touch.x = event.stageX;
|
touch.gestouch_internal::updateLocation(event.stageX, event.stageY);
|
||||||
touch.y = event.stageY;
|
|
||||||
touch.sizeX = event.sizeX;
|
touch.sizeX = event.sizeX;
|
||||||
touch.sizeY = event.sizeY;
|
touch.sizeY = event.sizeY;
|
||||||
touch.pressure = event.pressure;
|
touch.pressure = event.pressure;
|
||||||
//TODO: conditional compilation?
|
//TODO: conditional compilation?
|
||||||
if (event.hasOwnProperty("timestamp"))
|
if (event.hasOwnProperty("timestamp"))
|
||||||
{
|
{
|
||||||
touch.time = event["timestamp"];
|
touch.gestouch_internal::setTime(event["timestamp"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
touch.time = getTimer();
|
touch.gestouch_internal::setTime(getTimer());
|
||||||
}
|
}
|
||||||
|
|
||||||
_gesturesManager.gestouch_internal::onTouchEnd(touch);
|
_gesturesManager.gestouch_internal::onTouchEnd(touch);
|
||||||
|
|
Loading…
Reference in a new issue