Copy link to clipboard
Copied
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!
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();
}
}
Copy link to clipboard
Copied
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();
}
}
Copy link to clipboard
Copied
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();
}
}
Copy link to clipboard
Copied
It's odd that kglad used a reserved word as a variable. Try changing the startDrag parts to be startDragX.
Copy link to clipboard
Copied
oops. fixed now.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now