# \[AS2\] setting and passing a variable problem

**URL:** <https://forum.kirupa.com/t/as2-setting-and-passing-a-variable-problem/289551>\
**Category:** flash\
**Created:** [June 1, 2009, 7:48pm UTC](https://forum.kirupa.com/t/as2-setting-and-passing-a-variable-problem/289551 "2009-06-01T19:48:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mindsplit](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@Mindsplit](https://forum.kirupa.com/u/Mindsplit)\
**Post date:** [June 1, 2009, 7:48pm UTC](https://forum.kirupa.com/t/as2-setting-and-passing-a-variable-problem/289551/1 "2009-06-01T19:48:45Z")

</div>

hey people,

im trying to set up a variable passing system where once the user clicks a button it sets a variable and then once the movie hits a certain frame an if statement checks the variable and sends the user off in the direction depending on what the variable is.

here is the code on the button

[COLOR=Red]on(release) {  
set(“global”, “variable1”);  
}[/COLOR]

and here is the if statement

[COLOR=Red]if (global = “variable1”){  
gotoAndPlay(“here”);  
} else if (global = “variable2”){  
gotoAndPlay(“thisplace”);  
}[/COLOR]

the code seems to be working on the first part as the movie goes to the “here” part but i cant get it to go to the “thisplace” section. am i doing something wrong?

any help would be appreciated

thanks!
