Gestouch
Gestouch copied to clipboard
GESTURE_BEGAN and GESTURE_ENDED not fired on iOS devices.
Got a code here (pretty much taken from the example code :
private function initGestures() : void
{
transformGesture = new TransformGesture(photoSprite);
transformGesture.addEventListener(org.gestouch.events.GestureEvent.GESTURE_BEGAN, onGesture);
transformGesture.addEventListener(org.gestouch.events.GestureEvent.GESTURE_CHANGED, onGesture);
transformGesture.addEventListener(org.gestouch.events.GestureEvent.GESTURE_ENDED, resumeScroll);
}
private function onGesture(event : org.gestouch.events.GestureEvent) : void
{
const gesture : TransformGesture = event.target as TransformGesture;
var matrix : Matrix = photoSprite.transform.matrix;
trace("Event type "+event.type);
trace("eventPhase "+event.eventPhase);
if (event.type == GestureEvent.GESTURE_BEGAN)
{
toggleScroll(true);
}
// Panning
matrix.translate(gesture.offsetX, gesture.offsetY);
photoSprite.transform.matrix = matrix;
if (gesture.scale != 1 || gesture.rotation != 0)
{
// Scale and rotation.
var transformPoint : Point = matrix.transformPoint(photoSprite.globalToLocal(gesture.location));
matrix.translate(-transformPoint.x, -transformPoint.y);
matrix.rotate(gesture.rotation);
matrix.scale(gesture.scale, gesture.scale);
matrix.translate(transformPoint.x, transformPoint.y);
photoSprite.transform.matrix = matrix;
}
}
private function toggleScroll(pause : Boolean) : void
{
if (pause)
{
scroll.verticalScrollingEnabled = false;
scroll.pauseScrolling();
}
else
{
scroll.verticalScrollingEnabled = true;
scroll.resumeScrolling();
}
}
private function resumeScroll(event : org.gestouch.events.GestureEvent) : void
{
toggleScroll(false);
}
The Transform gesture works fine both on Android and iOS, which is great, but I need to capture both GESTURE_BEGAN and GESTURE_ENDED as there's another scroll functionality on the whole page. So I listen for the began and end events to stop the entire screen scrolling and only deal with transforming the image.
While this works fine on Android , on iOS devices (tested on iPhone4 and iPad3) this does not work. The problem is GESTURE_BEGAN and GESTURE_ENDED is not being fired on iOS devices.
Any ideas why or how to fix this ?
Many thanks..
I've now found out this is ONLY happening when packaging with the new AIR 4+ faster packer (and -useLegacyAOT no switch) When using original packaging method -target ipa-test or ipa-debug etc, this works ok.
With the latest SDKs installed (AIR + Apache Flex) GESTURE_ENDED does actually never get fired at all. However, GESTURE_CANCELLED gets sometimes fired when ending the gesture. This seems to be a bug.