Skip to main content
Participant
July 10, 2018
Answered

Swipe Event Problem

  • July 10, 2018
  • 2 replies
  • 650 views

Hi, I am new in Adobe Animate  and I am working on a new application. I have two scenes in the second scene. I use the command to move the pictures using my finger and works with me. But in this photo I have a picture 1 and a picture 2 and a picture 3 I move from first to second to third Good but if I am on the first picture and move my finger Back to the second scene and I do not want that I want to keep it for this scene only I use this code :

/* Swipe Event

Swiping the stage executes a function containing your custom code. You can use this event to scroll text in a TextField or change states in your application.

Instructions:

1. Add your custom code on a new line after the lines that say "// Start your custom code" below.

*/

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler_2);

function fl_SwipeHandler_2(event:TransformGestureEvent):void

{

switch(event.offsetX)

{

// swiped right

case 1:

{

// Start your custom code

// This example code moves the selected object 20 pixels to the right.

btgn_ww.x += 2048;

// End your custom code

break;

}

// swiped left

case -1:

{

// Start your custom code

// This example code moves the selected object 20 pixels to the left.

btgn_ww.x -= 2048;

// End your custom code

break;

}

}

switch(event.offsetY)

{

// swiped down

case 1:

{

// Start your custom code

// This example code moves the selected object 20 pixels down.

btgn_ww.y += 20;

// End your custom code

break;

}

// swiped up

case -1:

{

// Start your custom code

// This example code moves the selected object 20 pixels up.

btgn_ww.y -= 20;

// End your custom code

break;

}

}

}

This topic has been closed for replies.
Correct answer JoãoCésar17023019

OK.

Please see if this what you want:

animate_cc_as3_swipe.fla - Google Drive

I did a small addition to the code but I'm sending the FLA because in this case is really important how the objects are aligned/structured.

function fl_SwipeHandler_2(event:TransformGestureEvent):void

{

     switch(event.offsetX)

     {

          case 1:

          {

               btgn_ww.x += 2048;

               break;

          }

          case -1:

          {

               btgn_ww.x -= 2048;

               break;

          }

     }

     // here we check the edges

     if (btgn_ww.x > 0)

          btgn_ww.x = 0;

     else if (btgn_ww.x < -(btgn_ww.width - stage.stageWidth))

          btgn_ww.x = -(btgn_ww.width - stage.stageWidth);

     switch(event.offsetY)

     {

          case 1:

          {

               btgn_ww.y += 20;

               break;

          }

          case -1:

          {

               btgn_ww.y -= 20;

               break;

          }

     }

}

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler_2);

Regards,

JC

2 replies

JoãoCésar17023019
Community Expert
Community Expert
July 10, 2018

Hi.

I don't know if I get what you want to achieve.

Is it possible that instead of scene you are actually referring to the stage?

Do you want to restrict the swipe to not allow the images edges (in your case, the left edge of the first image and the right edge of the third image) to go inside of the stage area? Is this it?

Participant
July 10, 2018

Yes true i want to have scrolling between the three pictures just do not go out to any other place

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
July 10, 2018

OK.

Please see if this what you want:

animate_cc_as3_swipe.fla - Google Drive

I did a small addition to the code but I'm sending the FLA because in this case is really important how the objects are aligned/structured.

function fl_SwipeHandler_2(event:TransformGestureEvent):void

{

     switch(event.offsetX)

     {

          case 1:

          {

               btgn_ww.x += 2048;

               break;

          }

          case -1:

          {

               btgn_ww.x -= 2048;

               break;

          }

     }

     // here we check the edges

     if (btgn_ww.x > 0)

          btgn_ww.x = 0;

     else if (btgn_ww.x < -(btgn_ww.width - stage.stageWidth))

          btgn_ww.x = -(btgn_ww.width - stage.stageWidth);

     switch(event.offsetY)

     {

          case 1:

          {

               btgn_ww.y += 20;

               break;

          }

          case -1:

          {

               btgn_ww.y -= 20;

               break;

          }

     }

}

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeHandler_2);

Regards,

JC

Participant
July 10, 2018

The Swipe continues to work until it comes out of the scene and enters into another scene and I do not want that I want to work within this scene only