• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Pan event

Explorer ,
Jul 08, 2019 Jul 08, 2019

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

TOPICS
ActionScript

Views

306

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2019 Jul 08, 2019

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 08, 2019 Jul 08, 2019

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 ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 12, 2019 Jul 12, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines