Rather than checking to see if the current frame is 2, I would suggest stopping the sound when the button is clicked, like so (with an example button named buttonToNextFrame):
buttonToNextFrame.addEventListener(MouseEvent.MOUSE_DOWN, goToNextFrame);
function goToNextFrame (e: MouseEvent) {
sound1.stop();
//Other stuff you would like done when the button is pressed.
gotoAndStop(2);
}
If there is a way to bypass the button to get to frame 2 and you still want the sound to stop, then you would have to either:
- stop the sound in every event/way used to get to frame 2
- stop the sound directly on frame 2 with a plain
sound1.stop()
Let me know if you have any further questions!