Skip to main content
Known Participant
May 10, 2011
Question

Zoom in/out in the gesture area

  • May 10, 2011
  • 2 replies
  • 17274 views

Hi,

i want to zoom in into a movieclip.

The zoom should zoom in the area where the gesture was taken.

In this moment i scale the movieclip and set the new x and y coordinates by myself.

This one works not as i wish.

Any ideas?

Best regards

This topic has been closed for replies.

2 replies

Participant
January 21, 2014

i want to zoom an image like this way that if i want view some detail of the image i zoom by two fingers and the image zoomed by the center point of my fingers! Like zoom an image on ipad,but the transformgestureevent of the as3.0 can not do this! is here anyone  can help me !and tell my some method to do this!

Colin Holgate
Inspiring
May 10, 2011

If you're using Flash CS 5.5 you can look at the code snippets for a good start. Here's the code for a pinch and zoom behavior:

/* Pinch to Zoom Event

Pinching the stage will zoom in on the selected object.

Instructions:

1. The symbol's registration and transformation points should be at the center.

2. The symbol should be the background of your application and sized to match the stage.

*/

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler);

function fl_ZoomHandler(event:TransformGestureEvent):void

{

instance_name_here.scaleX *= event.scaleX;

instance_name_here.scaleY *= event.scaleY;

}

If you mix that with the pan gesture, you get the typical iOS behavior of zooming in and panning around:
/* Pan Event
Pans the selected object on stage. The object to be panned is usually larger than the viewable area.
Instructions:
1. To pan all the objects on stage, place the objects in a single container movie clip and apply this snippet to that movie clip.
*/
Multitouch.inputMode = MultitouchInputMode.GESTURE;
instance_name_here.addEventListener(TransformGestureEvent.GESTURE_PAN, fl_PanHandler);
function fl_PanHandler(event:TransformGestureEvent):void
{
event.currentTarget.x += event.offsetX;
event.currentTarget.y += event.offsetY;
}
The whole code, without the instructions, would look like this:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
instance_name_here.addEventListener(TransformGestureEvent.GESTURE_PAN, fl_PanHandler);

stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler);

function fl_PanHandler(event:TransformGestureEvent):void
{
event.currentTarget.x += event.offsetX;
event.currentTarget.y += event.offsetY;
}
function fl_ZoomHandler(event:TransformGestureEvent):void

{

instance_name_here.scaleX *= event.scaleX;

instance_name_here.scaleY *= event.scaleY;

}

There is also a rotate event, though having all three mixed in can get too much!

Known Participant
May 12, 2011

Thank you,

my registration point was not in the center. That was the problem -.-