Copy link to clipboard
Copied
Hi!
I am using a Pan event and a Pinch to zoom event to move and zoom in and out a movieclip.
In order to restrict the zoom I am using the code:
{
if(movieClip_1.scaleX*event.scaleX > 1 && movieClip_1.scaleX*event.scaleX < 2)
}
My question is if there is any way to restrict also the pan event, so the movieclip never gets out of the limits of the screen.
Thank you all
AB
Copy link to clipboard
Copied
What is the intention of...
if(movieClip_1.scaleX*event.scaleX > 1 && movieClip_1.scaleX*event.scaleX < 2)
I don't see where that is restricting, it is just checking to see if the scale is between 1 and 2. What other code goes along with it? What is triggering the code?
Copy link to clipboard
Copied
Sorry Ned, it is just a zoom event, where I want to limit the amount of zoom in and out:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM, fl_ZoomHandler_3);
function fl_ZoomHandler_3(event:TransformGestureEvent):void
{
if(movieClip_1.scaleX*event.scaleX > 1 && movieClip_1.scaleX*event.scaleX < 2)
{
movieClip_1.scaleX *= event.scaleX;
movieClip_1.scaleY *= event.scaleY;
}}
I am not sure if this is the right way to do it (if it isn't please let me know) but it is working for now.
I am also using a pan Event:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
movieClip_1.addEventListener(TransformGestureEvent.GESTURE_PAN, fl_PanHandler_4);
function fl_PanHandler_4(event:TransformGestureEvent):void
{
event.currentTarget.x += event.offsetX;
event.currentTarget.y += event.offsetY;
}
and for this one I would like to limit the panning so the map doesn't go out of the screen, and was wondering if there is something similar to this bit
{
if(movieClip_1.scaleX*event.scaleX > 1 && movieClip_1.scaleX*event.scaleX < 2)
{
to limit the pan.
Can you understand now? My english is not helping I suppose
Thank you any way ...
Copy link to clipboard
Copied
Any help here
...
I am not sure if this is the right way to do it but if there is any other please let me know ....
Thanks
AB