Using custom GestureEvent and TransformGestureEvent from now on

This commit is contained in:
Pavel fljot 2012-03-06 01:12:46 +02:00
parent 06df91ce04
commit 5f28227c75
12 changed files with 149 additions and 146 deletions

View file

@ -1,7 +1,6 @@
package org.gestouch.events
{
import flash.events.Event;
import flash.events.GestureEvent;
/**
@ -12,15 +11,18 @@ package org.gestouch.events
public static const GESTURE_LONG_PRESS:String = "gestureLongPress";
public function LongPressGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, phase:String = null, localX:Number = 0, localY:Number = 0)
public function LongPressGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false,
gestureState:uint = 0,
stageX:Number = 0, stageY:Number = 0,
localX:Number = 0, localY:Number = 0)
{
super(type, bubbles, cancelable, phase, localX, localY);
super(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY);
}
override public function clone():Event
{
return new LongPressGestureEvent(type, bubbles, cancelable, phase, localX, localY);
return new LongPressGestureEvent(type, bubbles, cancelable, gestureState, localX, localY);
}

View file

@ -1,7 +1,6 @@
package org.gestouch.events
{
import flash.events.Event;
import flash.events.TransformGestureEvent;
/**
@ -12,15 +11,19 @@ package org.gestouch.events
public static const GESTURE_PAN:String = "gesturePan";
public function PanGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, phase:String = null, localX:Number = 0, localY:Number = 0, offsetX:Number = 0, offsetY:Number = 0)
public function PanGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false,
gestureState:uint = 0,
stageX:Number = 0, stageY:Number = 0,
localX:Number = 0, localY:Number = 0,
offsetX:Number = 0, offsetY:Number = 0)
{
super(type, bubbles, cancelable, phase, localX, localY, 1, 1, 0, offsetX, offsetY);
super(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, 1, 1, 0, offsetX, offsetY);
}
override public function clone():Event
{
return new PanGestureEvent(type, bubbles, cancelable, phase, localX, localY, offsetX, offsetY);
return new PanGestureEvent(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, offsetX, offsetY);
}

View file

@ -1,7 +1,6 @@
package org.gestouch.events
{
import flash.events.Event;
import flash.events.TransformGestureEvent;
/**
@ -12,15 +11,19 @@ package org.gestouch.events
public static const GESTURE_ROTATE:String = "gestureRotate";
public function RotateGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, phase:String = null, localX:Number = 0, localY:Number = 0, rotation:Number = 0)
public function RotateGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false,
gestureState:uint = 0,
stageX:Number = 0, stageY:Number = 0,
localX:Number = 0, localY:Number = 0,
rotation:Number = 0)
{
super(type, bubbles, cancelable, phase, localX, localY, 1, 1, rotation, localX, localY);
super(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, 1, 1, rotation);
}
override public function clone():Event
{
return new RotateGestureEvent(type, bubbles, cancelable, phase, localX, localY, rotation);
return new RotateGestureEvent(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, rotation);
}

View file

@ -1,7 +1,6 @@
package org.gestouch.events
{
import flash.events.Event;
import flash.events.TransformGestureEvent;
/**
@ -12,15 +11,19 @@ package org.gestouch.events
public static const GESTURE_SWIPE:String = "gestureSwipe";
public function SwipeGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, phase:String = null, localX:Number = 0, localY:Number = 0, offsetX:Number = 0, offsetY:Number = 0)
public function SwipeGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false,
gestureState:uint = 0,
stageX:Number = 0, stageY:Number = 0,
localX:Number = 0, localY:Number = 0,
offsetX:Number = 0, offsetY:Number = 0)
{
super(type, bubbles, cancelable, phase, localX, localY, 1, 1, 0, offsetX, offsetY);
super(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, 1, 1, 0, offsetX, offsetY);
}
override public function clone():Event
{
return new SwipeGestureEvent(type, bubbles, cancelable, phase, localX, localY, offsetX, offsetY);
return new SwipeGestureEvent(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, offsetX, offsetY);
}

View file

@ -1,7 +1,6 @@
package org.gestouch.events
{
import flash.events.Event;
import flash.events.GestureEvent;
/**
@ -12,15 +11,17 @@ package org.gestouch.events
public static const GESTURE_TAP:String = "gestureTap";
public function TapGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, phase:String = null, localX:Number = 0, localY:Number = 0)
public function TapGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false,
gestureState:uint = 0, stageX:Number = 0, stageY:Number = 0,
localX:Number = 0, localY:Number = 0)
{
super(type, bubbles, cancelable, phase, localX, localY);
super(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY);
}
override public function clone():Event
{
return new TapGestureEvent(type, bubbles, cancelable, phase, localX, localY);
return new TapGestureEvent(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY);
}

View file

@ -1,7 +1,6 @@
package org.gestouch.events
{
import flash.events.Event;
import flash.events.TransformGestureEvent;
/**
@ -12,15 +11,19 @@ package org.gestouch.events
public static const GESTURE_ZOOM:String = "gestureZoom";
public function ZoomGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, phase:String = null, localX:Number = 0, localY:Number = 0, scaleX:Number = 1, scaleY:Number = 1)
public function ZoomGestureEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false,
gestureState:uint = 0,
stageX:Number = 0, stageY:Number = 0,
localX:Number = 0, localY:Number = 0,
scaleX:Number = 1.0, scaleY:Number = 1.0)
{
super(type, bubbles, cancelable, phase, localX, localY, scaleX, scaleY);
super(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, scaleX, scaleY);
}
override public function clone():Event
{
return new ZoomGestureEvent(type, bubbles, cancelable, phase, localX, localY, scaleX, scaleY);
return new ZoomGestureEvent(type, bubbles, cancelable, gestureState, stageX, stageY, localX, localY, scaleX, scaleY);
}

View file

@ -5,7 +5,6 @@ package org.gestouch.gestures
import org.gestouch.events.LongPressGestureEvent;
import flash.display.InteractiveObject;
import flash.events.GesturePhase;
import flash.events.TimerEvent;
import flash.utils.Timer;
@ -124,7 +123,8 @@ package org.gestouch.gestures
updateLocation();
if (setState(GestureState.CHANGED) && hasEventListener(LongPressGestureEvent.GESTURE_LONG_PRESS))
{
dispatchEvent(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, false, false, GesturePhase.UPDATE, _localLocation.x, _localLocation.y));
dispatchEvent(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, false, false, GestureState.CHANGED,
_location.x, _location.y, _localLocation.x, _localLocation.y));
}
}
}
@ -140,7 +140,8 @@ package org.gestouch.gestures
updateLocation();
if (setState(GestureState.ENDED) && hasEventListener(LongPressGestureEvent.GESTURE_LONG_PRESS))
{
dispatchEvent(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, false, false, GesturePhase.END, _localLocation.x, _localLocation.y));
dispatchEvent(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, false, false, GestureState.ENDED,
_location.x, _location.y, _localLocation.x, _localLocation.y));
}
}
else
@ -170,7 +171,8 @@ package org.gestouch.gestures
updateLocation();
if (setState(GestureState.BEGAN) && hasEventListener(LongPressGestureEvent.GESTURE_LONG_PRESS))
{
dispatchEvent(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, false, false, GesturePhase.BEGIN, _localLocation.x, _localLocation.y));
dispatchEvent(new LongPressGestureEvent(LongPressGestureEvent.GESTURE_LONG_PRESS, false, false, GestureState.BEGAN,
_location.x, _location.y, _localLocation.x, _localLocation.y));
}
}
}

View file

@ -5,7 +5,6 @@ package org.gestouch.gestures
import org.gestouch.events.PanGestureEvent;
import flash.display.InteractiveObject;
import flash.events.GesturePhase;
import flash.geom.Point;
[Event(name="gesturePan", type="org.gestouch.events.PanGestureEvent")]
@ -155,7 +154,8 @@ package org.gestouch.gestures
if (setState(GestureState.BEGAN) && hasEventListener(PanGestureEvent.GESTURE_PAN))
{
dispatchEvent(new PanGestureEvent(PanGestureEvent.GESTURE_PAN, false, false, GesturePhase.BEGIN, _localLocation.x, _localLocation.y, offset.x, offset.y));
dispatchEvent(new PanGestureEvent(PanGestureEvent.GESTURE_PAN, false, false, GestureState.BEGAN,
_location.x, _location.y, _localLocation.x, _localLocation.y, offset.x, offset.y));
}
}
}
@ -169,7 +169,8 @@ package org.gestouch.gestures
if (setState(GestureState.CHANGED) && hasEventListener(PanGestureEvent.GESTURE_PAN))
{
dispatchEvent(new PanGestureEvent(PanGestureEvent.GESTURE_PAN, false, false, GesturePhase.UPDATE, _localLocation.x, _localLocation.y, offsetX, offsetY));
dispatchEvent(new PanGestureEvent(PanGestureEvent.GESTURE_PAN, false, false, GestureState.CHANGED,
_location.x, _location.y, _localLocation.x, _localLocation.y, offsetX, offsetY));
}
}
}
@ -187,7 +188,8 @@ package org.gestouch.gestures
{
if (setState(GestureState.ENDED) && hasEventListener(PanGestureEvent.GESTURE_PAN))
{
dispatchEvent(new PanGestureEvent(PanGestureEvent.GESTURE_PAN, false, false, GesturePhase.END, _localLocation.x, _localLocation.y, 0, 0));
dispatchEvent(new PanGestureEvent(PanGestureEvent.GESTURE_PAN, false, false, GestureState.ENDED,
_location.x, _location.y, _localLocation.x, _localLocation.y, 0, 0));
}
}
}

View file

@ -6,13 +6,11 @@ package org.gestouch.gestures
import org.gestouch.utils.GestureUtils;
import flash.display.InteractiveObject;
import flash.events.GesturePhase;
import flash.geom.Point;
[Event(name="gestureRotate", type="org.gestouch.events.RotateGestureEvent")]
/**
* TODO:
* -location
* -check native behavior on iDevice
*
* @author Pavel fljot
@ -21,9 +19,9 @@ package org.gestouch.gestures
{
public var slop:Number = Gesture.DEFAULT_SLOP >> 1;
protected var _rotationVector:Point = new Point();
protected var _firstTouch:Touch;
protected var _secondTouch:Touch;
protected var _touch1:Touch;
protected var _touch2:Touch;
protected var _transformVector:Point;
public function RotateGesture(target:InteractiveObject = null)
@ -65,68 +63,53 @@ package org.gestouch.gestures
if (touchesCount == 1)
{
_firstTouch = touch;
_touch1 = touch;
}
else
{
_secondTouch = touch;
_touch2 = touch;
_rotationVector = _secondTouch.location.subtract(_firstTouch.location);
_transformVector = _touch2.location.subtract(_touch1.location);
}
}
override protected function onTouchMove(touch:Touch):void
{
if (touch.id == _firstTouch.id)
if (touchesCount < 2)
return;
var recognized:Boolean = true;
if (state == GestureState.POSSIBLE && slop > 0 && touch.locationOffset.length < slop)
{
_firstTouch = touch;
}
else
{
_secondTouch = touch;
recognized = false;
}
if (touchesCount == 2)
if (recognized)
{
var recognized:Boolean;
var currTransformVector:Point = _touch2.location.subtract(_touch1.location);
var rotation:Number = Math.atan2(currTransformVector.y, currTransformVector.x) - Math.atan2(_transformVector.y, _transformVector.x);
rotation *= GestureUtils.RADIANS_TO_DEGREES;
_transformVector.x = currTransformVector.x;
_transformVector.y = currTransformVector.y;
updateLocation();
if (state == GestureState.POSSIBLE)
{
// we start once any finger moved enough
if (touch.locationOffset.length > slop || slop != slop)//faster isNaN(slop)
if (setState(GestureState.BEGAN) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
{
recognized = true;
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GestureState.BEGAN,
_location.x, _location.y, _localLocation.x, _localLocation.y, rotation));
}
}
else
{
recognized = true;
}
if (recognized)
{
var currRotationVector:Point = _secondTouch.location.subtract(_firstTouch.location);
var rotation:Number = Math.atan2(currRotationVector.y, currRotationVector.x) - Math.atan2(_rotationVector.y, _rotationVector.x);
rotation *= GestureUtils.RADIANS_TO_DEGREES;
_rotationVector.x = currRotationVector.x;
_rotationVector.y = currRotationVector.y;
updateLocation();
if (state == GestureState.POSSIBLE)
if (setState(GestureState.CHANGED) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
{
if (setState(GestureState.BEGAN) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
{
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GesturePhase.BEGIN, _localLocation.x, _localLocation.y, rotation));
}
}
else
{
if (setState(GestureState.CHANGED) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
{
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GesturePhase.UPDATE, _localLocation.x, _localLocation.y, rotation));
}
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GestureState.CHANGED,
_location.x, _location.y, _localLocation.x, _localLocation.y, rotation));
}
}
}
@ -141,7 +124,8 @@ package org.gestouch.gestures
{
if (setState(GestureState.ENDED) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
{
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GesturePhase.END, _localLocation.x, _localLocation.y, 0));
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GestureState.ENDED,
_location.x, _location.y, _localLocation.x, _localLocation.y, 0));
}
}
else if (state == GestureState.POSSIBLE)
@ -151,16 +135,19 @@ package org.gestouch.gestures
}
else// == 1
{
if (touch.id == _firstTouch.id)
if (touch == _touch1)
{
_firstTouch = _secondTouch;
_touch1 = _touch2;
}
_touch2 = null;
if (state == GestureState.BEGAN || state == GestureState.CHANGED)
{
updateLocation();
if (setState(GestureState.CHANGED) && hasEventListener(RotateGestureEvent.GESTURE_ROTATE))
{
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GesturePhase.UPDATE, _localLocation.x, _localLocation.y, 0));
dispatchEvent(new RotateGestureEvent(RotateGestureEvent.GESTURE_ROTATE, false, false, GestureState.CHANGED,
_location.x, _location.y, _localLocation.x, _localLocation.y, 0));
}
}
}

View file

@ -5,7 +5,6 @@ package org.gestouch.gestures
import org.gestouch.events.SwipeGestureEvent;
import flash.display.InteractiveObject;
import flash.events.GesturePhase;
import flash.geom.Point;
import flash.system.Capabilities;
@ -72,14 +71,19 @@ package org.gestouch.gestures
{
if (touchesCount > numTouchesRequired)
{
//TODO: or ignore?
setState(GestureState.FAILED);
return;
}
if (touchesCount == 1)
{
// Because we want to fail as quick as possible
_startTime = touch.time;
}
if (touchesCount == numTouchesRequired)
{
updateLocation();
_startTime = touch.time;
// cache direction condition for performance
_noDirection = (SwipeGestureDirection.ORTHOGONAL & direction) == 0;
@ -100,7 +104,6 @@ package org.gestouch.gestures
var timeDelta:int = touch.time - _startTime;
var vel:Number = offsetLength / timeDelta;
var absVel:Number = vel > 0 ? vel : -vel;//faster Math.abs()
// trace(_offset, _offset.length, ".....velocity:", vel);
if (offsetLength < Gesture.DEFAULT_SLOP)
{
@ -123,7 +126,9 @@ package org.gestouch.gestures
{
if (setState(GestureState.RECOGNIZED) && hasEventListener(SwipeGestureEvent.GESTURE_SWIPE))
{
dispatchEvent(new SwipeGestureEvent(SwipeGestureEvent.GESTURE_SWIPE, false, false, GesturePhase.ALL, _localLocation.x, _localLocation.y, _offset.x, _offset.y));
_localLocation = target.globalToLocal(_location);//refresh local location in case target moved
dispatchEvent(new SwipeGestureEvent(SwipeGestureEvent.GESTURE_SWIPE, false, false, GestureState.RECOGNIZED,
_location.x, _location.y, _localLocation.x, _localLocation.y, _offset.x, _offset.y));
}
}
}
@ -154,7 +159,9 @@ package org.gestouch.gestures
{
if (setState(GestureState.RECOGNIZED) && hasEventListener(SwipeGestureEvent.GESTURE_SWIPE))
{
dispatchEvent(new SwipeGestureEvent(SwipeGestureEvent.GESTURE_SWIPE, false, false, GesturePhase.ALL, _localLocation.x, _localLocation.y, _offset.x, 0));
_localLocation = target.globalToLocal(_location);//refresh local location in case target moved
dispatchEvent(new SwipeGestureEvent(SwipeGestureEvent.GESTURE_SWIPE, false, false, GestureState.RECOGNIZED,
_location.x, _location.y, _localLocation.x, _localLocation.y, _offset.x, 0));
}
}
}
@ -177,7 +184,9 @@ package org.gestouch.gestures
{
if (setState(GestureState.RECOGNIZED) && hasEventListener(SwipeGestureEvent.GESTURE_SWIPE))
{
dispatchEvent(new SwipeGestureEvent(SwipeGestureEvent.GESTURE_SWIPE, false, false, GesturePhase.ALL, _localLocation.x, _localLocation.y, 0, _offset.y));
_localLocation = target.globalToLocal(_location);//refresh local location in case target moved
dispatchEvent(new SwipeGestureEvent(SwipeGestureEvent.GESTURE_SWIPE, false, false, GestureState.RECOGNIZED,
_location.x, _location.y, _localLocation.x, _localLocation.y, 0, _offset.y));
}
}
}

View file

@ -5,11 +5,11 @@ package org.gestouch.gestures
import org.gestouch.events.TapGestureEvent;
import flash.display.InteractiveObject;
import flash.events.GesturePhase;
import flash.events.TimerEvent;
import flash.utils.Timer;
[Event(name="gestureTap", type="org.gestouch.events.TapGestureEvent")]
/**
* TODO: check failing conditions (iDevice)
*
@ -139,7 +139,8 @@ package org.gestouch.gestures
updateLocation();
if (setState(GestureState.RECOGNIZED) && hasEventListener(TapGestureEvent.GESTURE_TAP))
{
dispatchEvent(new TapGestureEvent(TapGestureEvent.GESTURE_TAP, false, false, GesturePhase.ALL, _localLocation.x, _localLocation.y));
dispatchEvent(new TapGestureEvent(TapGestureEvent.GESTURE_TAP, false, false, GestureState.RECOGNIZED,
_location.x, _location.y, _localLocation.x, _localLocation.y));
}
}
else

View file

@ -5,13 +5,11 @@ package org.gestouch.gestures
import org.gestouch.events.ZoomGestureEvent;
import flash.display.InteractiveObject;
import flash.events.GesturePhase;
import flash.geom.Point;
[Event(name="gestureZoom", type="org.gestouch.events.ZoomGestureEvent")]
/**
* TODO:
* -location
* -check native behavior on iDevice
*
* @author Pavel fljot
@ -21,9 +19,9 @@ package org.gestouch.gestures
public var slop:Number = Gesture.DEFAULT_SLOP >> 1;
public var lockAspectRatio:Boolean = true;
protected var _scaleVector:Point = new Point();
protected var _firstTouch:Touch;
protected var _secondTouch:Touch;
protected var _touch1:Touch;
protected var _touch2:Touch;
protected var _transformVector:Point;
public function ZoomGesture(target:InteractiveObject = null)
@ -65,78 +63,63 @@ package org.gestouch.gestures
if (touchesCount == 1)
{
_firstTouch = touch;
_touch1 = touch;
}
else// == 2
{
_secondTouch = touch;
_touch2 = touch;
_scaleVector = _secondTouch.location.subtract(_firstTouch.location);
_transformVector = _touch2.location.subtract(_touch1.location);
}
}
override protected function onTouchMove(touch:Touch):void
{
if (touch.id == _firstTouch.id)
if (touchesCount < 2)
return;
var recognized:Boolean = true;
if (state == GestureState.POSSIBLE && slop > 0 && touch.locationOffset.length < slop)
{
_firstTouch = touch;
}
else
{
_secondTouch = touch;
recognized = false;
}
if (touchesCount == 2)
if (recognized)
{
var recognized:Boolean;
var currTransformVector:Point = _touch2.location.subtract(_touch1.location);
var scaleX:Number;
var scaleY:Number;
if (lockAspectRatio)
{
scaleX = scaleY = currTransformVector.length / _transformVector.length;
}
else
{
scaleX = currTransformVector.x / _transformVector.x;
scaleY = currTransformVector.y / _transformVector.y;
}
_transformVector.x = currTransformVector.x;
_transformVector.y = currTransformVector.y;
updateLocation();
if (state == GestureState.POSSIBLE)
{
// Check if finger moved enough for gesture to be recognized
if (touch.locationOffset.length > slop || slop != slop)//faster isNaN(slop)
if (setState(GestureState.BEGAN) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
{
recognized = true;
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GestureState.BEGAN,
_location.x, _location.y, _localLocation.x, _localLocation.y, scaleX, scaleY));
}
}
else
{
recognized = true;
}
if (recognized)
{
var currScaleVector:Point = _secondTouch.location.subtract(_firstTouch.location);
var scaleX:Number;
var scaleY:Number;
if (lockAspectRatio)
if (setState(GestureState.CHANGED) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
{
scaleX = scaleY = currScaleVector.length / _scaleVector.length;
}
else
{
scaleX = currScaleVector.x / _scaleVector.x;
scaleY = currScaleVector.y / _scaleVector.y;
}
_scaleVector.x = currScaleVector.x;
_scaleVector.y = currScaleVector.y;
updateLocation();
if (state == GestureState.POSSIBLE)
{
if (setState(GestureState.BEGAN) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
{
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GesturePhase.BEGIN, _localLocation.x, _localLocation.y, scaleX, scaleY));
}
}
else
{
if (setState(GestureState.CHANGED) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
{
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GesturePhase.UPDATE, _localLocation.x, _localLocation.y, scaleX, scaleY));
}
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GestureState.CHANGED,
_location.x, _location.y, _localLocation.x, _localLocation.y, scaleX, scaleY));
}
}
}
@ -151,7 +134,8 @@ package org.gestouch.gestures
{
if (setState(GestureState.ENDED) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
{
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GesturePhase.END, _localLocation.x, _localLocation.y, 1, 1));
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GestureState.ENDED,
_location.x, _location.y, _localLocation.x, _localLocation.y, 1, 1));
}
}
else if (state == GestureState.POSSIBLE)
@ -161,16 +145,19 @@ package org.gestouch.gestures
}
else//== 1
{
if (touch.id == _firstTouch.id)
if (touch == _touch1)
{
_firstTouch = _secondTouch;
_touch1 = _touch2;
}
_touch2 = null;
if (state == GestureState.BEGAN || state == GestureState.CHANGED)
{
updateLocation();
if (setState(GestureState.CHANGED) && hasEventListener(ZoomGestureEvent.GESTURE_ZOOM))
{
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GesturePhase.UPDATE, _localLocation.x, _localLocation.y, 1, 1));
dispatchEvent(new ZoomGestureEvent(ZoomGestureEvent.GESTURE_ZOOM, false, false, GestureState.CHANGED,
_location.x, _location.y, _localLocation.x, _localLocation.y, 1, 1));
}
}
}