gotoAndPlay inside function bypasses stop
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
