Scale

From GestureWorks Tutorials
(Redirected from Scale)
Jump to: navigation, search

Logo gestureworks flash.png

 

GWGestureEvent.SCALE

N finger scale lg.jpg

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:

  1. mytouchsprite.gestureList = {"n-scale":true};

Register an event for the gesture by listening for the 'SCALE' GWGestureEvent:

  1. myTouchSprite.addEventListener(GWGestureEvent.SCALE, gestureScaleHandler);

Finally, implement the script(s) that you want to respond to the event in a custom handler:

  1. private function gestureScaleHandler(event:GWGestureEvent):void {
  2.     trace("g scale: ", event.value.dsx, event.value.dsy);
  3.     event.target.$scaleX += event.value.scale_dsx;
  4.     event.target.$scaleY += event.value.scale_dsy;
  5. }

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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox