If variable {gotoAndPlay} help?

Hello all, working on a small test project to learn a technique for a larger one.
I have a variable that starts with a value of 0, a button which when clicked adds 1 to the value of said variable, and an if statement that says when the variable reaches a value of 10, gotoAndPlay a labeled frame further down the timeline. There is also a dynamic textbox that displays the value of said variable, starting at 0 and increasing +1 each time the button is pressed.

Seems simple, right? Everything works except my if/gotoAndPlay statement, and I think it’s something small. At the moment it just keeps adding value to the variable/textbox display but doesn’t gotoAndPlay the “ending” (see code). Any help for a beginner? Using Flash CS4 and AS2.

Code in frame 1 of actions layer:


stop();

var show=0;

if (show==10) {
    gotoAndPlay(ending)}

Code on button:


on (release) {
    show+=1;
}