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:

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

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

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

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

3
4
5
6
7
8
private function gestureScaleHandler(event:GWGestureEvent):void
{
    trace("g scale: ", event.value.dsx, event.value.dsy);
    event.target.$scaleX += event.value.dsx;
    event.target.$scaleY += event.value.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.