# Help with if then / Varialbes / animation

**URL:** https://forum.kirupa.com/t/help-with-if-then-varialbes-animation/295617
**Category:** Uncategorized
**Created:** [September 2, 2009, 2:43am UTC](https://forum.kirupa.com/t/help-with-if-then-varialbes-animation/295617 "2009-09-02T02:43:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![cayoyay](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@cayoyay](https://forum.kirupa.com/u/cayoyay)
#### Post date: [September 2, 2009, 2:43am UTC](https://forum.kirupa.com/t/help-with-if-then-varialbes-animation/295617/1 "2009-09-02T02:43:02Z")

</div>

I am by no means an expert in AS, and you will quickly figured that one out with my request for help… but here I go… I am trying to do a keyframed animation that is driven by variables that determine which label is the “go to and play” going to go next… So I have 3 items with intro and exit animation and I want the variable to define where is it going after it does the exit animation  
I know it may not be the best way, but this is as much as I know… so please bare with me because arrays confuse the hell out of me

so here is a look at the time line [http://taleo.com/LP/h3lp/timeline.gif](http://taleo.com/LP/h3lp/timeline.gif)  
and here is a look of the “animation” so far [http://taleo.com/LP/h3lp/grid2.html](http://taleo.com/LP/h3lp/grid2.html)

The problem is that I have to click twice or even 3 times to get ti go where I want if I click on the SX or the TX

here is the code

\> Button for KX  
on (release) {  
gotoAndPlay(“Scene 1”, “KXO”);  
TG = 1;  
}

\> Button for SX  
on (release) {  
gotoAndPlay(“Scene 1”, “SXO”);  
TG = 2;  
}

\> Button for TX  
on (release) {  
gotoAndPlay(“Scene 1”, “TXO”);  
TG = 3;  
}

\> On the Timeline at the end of KXO, SXO and TXO I have the following actions

if (TG == 1) {  
gotoAndPlay(“Scene 1”, “KX”);

} else if (TG == 2) {  
gotoAndPlay(“Scene 1”, “SX”);

} else if (TG == 3) {  
gotoAndPlay(“Scene 1”, “TX”);

}

what am I doing wrong? please let me know if this makes sense
