# If variable {gotoAndPlay} help?

**URL:** <https://forum.kirupa.com/t/if-variable-gotoandplay-help/307142>\
**Category:** Uncategorized\
**Created:** [March 29, 2010, 1:50pm UTC](https://forum.kirupa.com/t/if-variable-gotoandplay-help/307142 "2010-03-29T13:50:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfugu](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@sfugu](https://forum.kirupa.com/u/sfugu)\
**Post date:** [March 29, 2010, 1:50pm UTC](https://forum.kirupa.com/t/if-variable-gotoandplay-help/307142/1 "2010-03-29T13:50:51Z")

</div>

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:

```auto

stop();

var show=0;

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

```

Code on button:

```auto

on (release) {
    show+=1;
}

```
