Skip to main content
Participating Frequently
September 14, 2015
Answered

Swipe to Go to Next/Previous Scene and Play Air for iOS

  • September 14, 2015
  • 1 reply
  • 746 views

Hi, I am using this action script to create a simple swipe App.

/* Swipe to Go to Next/Previous Scene and Play

Swiping the stage moves the playhead to the next/previous scene in the timeline and continues playback in that scene.

*/

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousScene_5);

function fl_SwipeToGoToNextPreviousScene_5(event:TransformGestureEvent):void

{

  if(event.offsetX == 1)

  {

  // swiped right

  prevScene();

  }

  else if(event.offsetX == -1)

  {

  // swiped left

  nextScene();

  }

}

This works fine if I only have two scenes but I have more than that. At the moment it will reset to the start and not go past scene 2.

Do I need to amend this code here?

  if(event.offsetX == 1)

  {

  // swiped right

  prevScene();

  }

  else if(event.offsetX == -1)

  {

  // swiped left

  nextScene();

  }

}

Any advice would be helpful.

Thanks

This topic has been closed for replies.
Correct answer kglad

you need to add a stop() to each scene.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 15, 2015

you need to add a stop() to each scene.

Participating Frequently
September 16, 2015

Thank you, will give it a try.

kglad
Community Expert
Community Expert
September 16, 2015

you're welcome.