Highlighted

gotoAndPlay inside function bypasses stop

Participant ,
Aug 17, 2019

Copy link to clipboard

Copied

I've got a simple 'slider' movieclip which moves from left to right with this.stop() at frame 0, 40 and 80. In the root I've got a button which is set like this:

this.stop();

target = this.sliding;

this.buttonright.addEventListener("click", slideright.bind(this));

function slideright() {

  target.gotoAndPlay(39);

}

So when I click it it starts playing that slider movieclip from its frame 39. Which works the first time: it plays from frame 39 and stops at frame 40 as there is a this.stop() there. The second time I click the button however it starts playing from the slider's frame 39 again, but then bypasses the this.stop() that is in its frame 40 and continues to play until it reaches frame 80.

Why is this and how can I prevent it?

I know it doesn't make much sense playing that clip from frame 39 when it already stops at 40. But the point is that when I use gotoAndPlay(1) to gotoAndPlay(38) it works and always stops at frame 40. But when I use gotoAndPlay(39) it only works the first time and the next time I click the this.stop() is bypassed for some reason. And I would like to know why and how to fix it.

The file if you're interested: WeTransfer

Views

91

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

gotoAndPlay inside function bypasses stop

Participant ,
Aug 17, 2019

Copy link to clipboard

Copied

I've got a simple 'slider' movieclip which moves from left to right with this.stop() at frame 0, 40 and 80. In the root I've got a button which is set like this:

this.stop();

target = this.sliding;

this.buttonright.addEventListener("click", slideright.bind(this));

function slideright() {

  target.gotoAndPlay(39);

}

So when I click it it starts playing that slider movieclip from its frame 39. Which works the first time: it plays from frame 39 and stops at frame 40 as there is a this.stop() there. The second time I click the button however it starts playing from the slider's frame 39 again, but then bypasses the this.stop() that is in its frame 40 and continues to play until it reaches frame 80.

Why is this and how can I prevent it?

I know it doesn't make much sense playing that clip from frame 39 when it already stops at 40. But the point is that when I use gotoAndPlay(1) to gotoAndPlay(38) it works and always stops at frame 40. But when I use gotoAndPlay(39) it only works the first time and the next time I click the this.stop() is bypassed for some reason. And I would like to know why and how to fix it.

The file if you're interested: WeTransfer

Views

92

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 17, 2019 0
Adobe Community Professional ,
Aug 17, 2019

Copy link to clipboard

Copied

your sliding movieclip this.stop()'s are in frames 0, 39 and 79, not 0, 40 and 80.  ie, fix your code or your stops.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2019 1
Participant ,
Aug 17, 2019

Copy link to clipboard

Copied

Don't think so? In my movieclips I've got my this.stop();s in frames 40 and 80.

Schermafbeelding 2019-08-17 om 18.08.35.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2019 0
Adobe Community Professional ,
Aug 17, 2019

Copy link to clipboard

Copied

canvas/html5 frames are numbered starting with frame 0.  what looks to you like frames 40 and 80, are frames 39 and 79.

you can use alert(this.currentFrame) or console.log(this.currentFrame) on any frame to see the correct reference you should be using.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2019 1
ClayUUID LATEST
Adobe Community Professional ,
Aug 17, 2019

Copy link to clipboard

Copied

jiggy1965  wrote

Don't think so? In my movieclips I've got my this.stop();s in frames 40 and 80.

Okay, now show us frame 0 on the timeline.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2019 0