Help with if then / Varialbes / animation

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
and here is a look of the “animation” so far

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