Scale
GWGestureEvent.SCALE
Using the Scale Gesture
Calculates the change in relative separation of the touch points on an touch object.
Mechanics and Code Samples
To register a ‘scale’ event, the user places two or more fingers on an object and slides their fingers toward and away from one another.
Enable the Scale gesture on a TouchSprite ("myTouchSprite" in this example) by adding the gesture to the gestureList property for the TouchSprite:
- mytouchsprite.gestureList = {"n-scale":true};
Register an event for the gesture by listening for the 'SCALE' GWGestureEvent:
- myTouchSprite.addEventListener(GWGestureEvent.SCALE, gestureScaleHandler);
Finally, implement the script(s) that you want to respond to the event in a custom handler:
- private function gestureScaleHandler(event:GWGestureEvent):void {
- trace("g scale: ", event.value.dsx, event.value.dsy);
- event.target.$scaleX += event.value.scale_dsx;
- event.target.$scaleY += event.value.scale_dsy;
- }
In this example, the x and y scale delta value of the Scale gesture is being sent to the Output window.
Gestures can be utilized with a number of touch points. For detailed information about this gesture and more, consult the GestureML Wiki.