Pinching and pulling are gestures that are often used on touch screens that support multitouch input. Bringing two fingers closer together will shrink an object, while spreading two fingers apart makes the object larger on the device.
This example draws a square within a Shape
object using the Graphics
API, adds it to the Stage
, and then sets up listeners for zoom gesture events in order to scale the Shape
appropriately:
1. First, import the following classes into your project:
import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.display.Stage; import flash.display.Sprite; import flash.display.Shape; import flash.events.TransformGestureEvent; import flash.ui.Multitouch; import flash.ui.MultitouchInputMode;
2. Declare a
Shape
object, upon which we will perform the gestures:private var box:Shape;
3. Next, construct a method to handle the creation of our
Sprite
and add it to theDisplayList:
protected function...