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

Frame advance by touch screen pressed and dragged.

Explorer ,
Mar 30, 2017 Mar 30, 2017

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!

Untitled-1.gif

TOPICS
ActionScript
569
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 , Mar 31, 2017 Mar 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();

}

}

Translate
Community Expert ,
Mar 31, 2017 Mar 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();

}

}

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
Explorer ,
Mar 31, 2017 Mar 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();

  }

}

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
LEGEND ,
Mar 31, 2017 Mar 31, 2017

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

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 ,
Mar 31, 2017 Mar 31, 2017

oops.  fixed now.

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
Explorer ,
Apr 01, 2017 Apr 01, 2017

Just one more question about the contract to finalize ... Can only do this with the use of a button? Why with a use there is no way to use other buttons that are in the layer below, so a doubt.

And thanks, it worked as expected!

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 ,
Apr 01, 2017 Apr 01, 2017

you can use the stage instead of a button or a transparent object or a movieclip, but if there's other mouse interactivity in your project that might be a consideration.

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
Explorer ,
Apr 02, 2017 Apr 02, 2017

How can I be using the touch function only in a given frame? I noticed that the same works in all the frames I add, I have even tried to use the "removeEventListener" of the functions, but without success.

Would you help 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 ,
Apr 02, 2017 Apr 02, 2017
LATEST

removing the mousedown event listener or the button will remove the drag to control.

if that failed for you, you must have done something incorrectly.  show your relevant code if you want help with that.

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