I've been fighting with an issue regarding multitouch in as3. I'm trying to make an app where the user should be able to move a picture around the stage (touch_point) as well as zoom on it by gesturing (pinch gesture). Is it even possible?
Thanks!!
I've been fighting with an issue regarding multitouch in as3. I'm trying to make an app where the user should be able to move a picture around the stage (touch_point) as well as zoom on it by gesturing (pinch gesture). Is it even possible?
Thanks!!
These functions will handle the pinch, zoom and dragging.
import flash.events.GestureEvent;
import flash.events.TransformGestureEvent;
import flash.events.GesturePhase;
import flash.events.Event;
import flash.events.MouseEvent;
function fl_ZoomHandler (e:TransformGestureEvent):void {
e.target.scaleX *= e.scaleX;
e.target.scaleY *= e.scaleY;
if (e.phase==GesturePhase.END) {
e.currentTarget.stopDrag();
}
}
function fl_StartDrag (e:MouseEvent):void {
e.currentTarget.startDrag (false);
theDragItem = e.currentTarget;
}
function fl_StopDrag (e:MouseEvent):void {
e.currentTarget.stopDrag();
}
function fl_RotateHandler (e:TransformGestureEvent):void {
e.target.rotation += e.rotation;
if (e.phase==GesturePhase.END) {
e.currentTarget.stopDrag();
}
}
And these are the event listeners to apply to the item you want to affect.
YOUROBJECT.addEventListener(MouseEvent.MOUSE_DOWN, fl_StartDrag, false, 0, true);
YOUROBJECT.addEventListener(MouseEvent.MOUSE_UP, fl_StopDrag, false, 0, true);
YOUROBJECT.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler, false, 0, true);
YOUROBJECT.addEventListener(TransformGestureEvent.GESTURE_ROTATE, fl_RotateHandler, false, 0, true);
MAYBE this could be usefull
http://help.adobe.com/en_US/as3/dev/WS1ca064e08d7aa93023c59dfc1257b16a3d6-7ffd.html
Handle gesture events in the same way as basic touch events. You can listen for a series of gesture events defined by the event type constants in the TransformGestureEvent class, the GestureEvent class and the PressAndTapGestureEvent class.
there's also a new question that arises.. press-and-tap? swipe? http://i.msdn.microsoft.com/dynimg/IC504532.png graphical explanation of each
this site is awesome
Viva StackOverflow!
Don't bother using both, you can easily do some adjustments with TouchEvent properties to make gesture events.