Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Swipe Event Problem

Community Beginner ,
Jul 10, 2018 Jul 10, 2018

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;

}

}

}

574
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 10, 2018 Jul 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;

          }

     }

...
Translate
Community Beginner ,
Jul 10, 2018 Jul 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

Translate
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
Community Expert ,
Jul 10, 2018 Jul 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?

Translate
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
Community Beginner ,
Jul 10, 2018 Jul 10, 2018

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

Translate
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
Community Expert ,
Jul 10, 2018 Jul 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

Translate
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
Community Beginner ,
Jul 10, 2018 Jul 10, 2018

Thank you very much for helping me

Translate
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
Community Expert ,
Jul 10, 2018 Jul 10, 2018
LATEST

You're welcome!

Translate
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