There are two main event that we’ll be using to build our multi-touch applications with the new Flash Builder 10.1: flash.events.TouchEvent and flash.events.TransformGestureEvent. Lets take a quick look at each one.
The new TouchEvent class is fired off by the flash player when the player detects a single touch. This class should look very familiar to those who are comfortable with the MouseEvent. It’s my current understanding that this event can only be fired on touch enabled Windows 7 machines. I have no doubt that this will change in the near future but as of this writing (November 09) Linux and OSX don’t have a clear way to dispatch the TouchEvent class.
Types include:
TouchEvent.TOUCH_BEGIN
TouchEvent.TOUCH_END
TouchEvent.TOUCH_MOVE
TouchEvent.TOUCH_OUT
TouchEvent.TOUCH_OVER
TouchEvent.TOUCH_ROLL_OUT
TouchEvent.TOUCH_ROLL_OVER
TouchEvent.TOUCH_TAP
The new TransformGestureEvent class is fired off by the flash player when the player detects a gesture from the operating system. OSX users will be familiar with the ‘Pinch’, ‘Zoom’ and ‘Pan’ feature that is commonly used via the newer trackpads on most Macintosh laptops. It’s important to note that OS 10.6 (Snow Leopard) is required for the flash player to consume these events from the trackpad correctly. The flash player makes use of these gestures and dispatches the appropriate type of TransformGestureEvent. Windows 7 can also dispatch these same gesture event types.
Types include:
TransformGestureEvent.GESTURE_PAN
TransformGestureEvent.GESTURE_ROTATE
TransformGestureEvent.GESTURE_SWIPE
TransformGestureEvent.GESTURE_ZOOM
A sample event might look like this:
[TransformGestureEvent type="gestureRotate" bubbles=true, cancelable=false phase=null localX=20 localY=20 stageX=20 stageY=20 scaleX=1 scaleY=1 rotation=0 offsetX=0 offsetY=0 ctrlKey=false altkey=false shiftKey=false commandKey=false controlKey=false]
Just like a mouse event the developer can handle that rotation event however they wanted. Most likely a developer might want to rotate the currentTarget of the TransformGestureEvent.
One requirement that might be overlooked is that you have to specify the type of events that your applications will be consuming.
This code is required:
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT
or
Multitouch.inputMode = MultitouchInputMode.GESTURE;
Your flash 10.1 or Adobe Air 2 application can switch between touch input modes but it can’t consume them both at the same time.
