Skip to main content
Inspiring
March 30, 2017
Answered

Frame advance by touch screen pressed and dragged.

  • March 30, 2017
  • 1 reply
  • 633 views

Hello users, I have a question regarding evolution. I would like to know if there is a method to advance or regress a given frame from the touchscreen by dragging the screen from right to left to advance 1 frame, say so.

can anybody help me? I'm grateful now!

This topic has been closed for replies.
Correct answer kglad

var startDrag:int;

var tret:int = ?;

your_btn.addEventListener(MouseEvent.MOUSE_DOWN,downF);

function downF(e:MouseEvent):void{

startDragX=e.stageX;

stage.addEventListener(MouseEvent.MOUSE_UP,upF);

}

function upF(e:MouseEvent):void{

if(e.stageX>startDragX+tret){

this.prevFrame();

} else if(e.stageX<startDragX-tret){

this.nextFrame();

}

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 31, 2017

var startDrag:int;

var tret:int = ?;

your_btn.addEventListener(MouseEvent.MOUSE_DOWN,downF);

function downF(e:MouseEvent):void{

startDragX=e.stageX;

stage.addEventListener(MouseEvent.MOUSE_UP,upF);

}

function upF(e:MouseEvent):void{

if(e.stageX>startDragX+tret){

this.prevFrame();

} else if(e.stageX<startDragX-tret){

this.nextFrame();

}

}

vvvverTAuthor
Inspiring
March 31, 2017

The compiler does not run because of an error, a conflict according to the compiler:

"There is a conflict with the inherited definition flash.play: Sprite: startDrag in namespace public"

Would you help me?

var tret:int = 1;

var startDrag: int;

your_btn.addEventListener(MouseEvent.MOUSE_DOWN, downF);

function downF(e:MouseEvent) : void {

  startDrag = e.stageX;

  stage.addEventListener(MouseEvent.MOUSE_UP, upF);

}

function upF(e:MouseEvent) : void {

  if(e.stageX > startDrag + tret) {

  this.prevFrame();

  } else if(e.stageX < startDrag - tret) {

  this.nextFrame();

  }

}

Colin Holgate
Inspiring
March 31, 2017

It's odd that kglad used a reserved word as a variable. Try changing the startDrag parts to be startDragX.