# Flash MX variable problem

**URL:** <https://forum.kirupa.com/t/flash-mx-variable-problem/57434>\
**Category:** flash\
**Created:** [July 13, 2004, 6:00am UTC](https://forum.kirupa.com/t/flash-mx-variable-problem/57434 "2004-07-13T06:00:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SandMan27](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@SandMan27](https://forum.kirupa.com/u/SandMan27)\
**Post date:** [July 13, 2004, 6:00am UTC](https://forum.kirupa.com/t/flash-mx-variable-problem/57434/1 "2004-07-13T06:00:05Z")

</div>

Ok, I’ve been working on this for hours and can’t figure it out.

I have a swf file that plays, and when a button is clicked it sets a global variable and loads a movie:  
on (release) {  
\_global.gateStat=0;  
loadMovieNum(“Security Cams.swf”, 5);  
}

Now, in the loaded movie, there is a button that checks the global variable and acts accordingly. (this is just the code I’m using to try and get it to work. It would be more complex later 😛 lol )

on (release){  
if (\_global.gateStat == 0) {  
gotoAndPlay(5);  
}

I’ve also tried

on (release){  
if (gateStat == 0) {  
gotoAndPlay(5);  
}

with no luck. Any suggestions?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2004, 1:52pm UTC](https://forum.kirupa.com/t/flash-mx-variable-problem/57434/2 "2004-07-13T13:52:13Z")

</div>

You want to play frame 5 of the main movie or the Security Cams movie?  
If you want to target the main movie, use _\_root_

```auto
_root.gotoAndPlay(5);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 13, 2004, 4:15pm UTC](https://forum.kirupa.com/t/flash-mx-variable-problem/57434/3 "2004-07-13T16:15:47Z")

</div>

I want the security cams movie to go to frame 5, which it does without the if statement. The problem is, when I include the if statment it doesn’t seem to reconize the global variable. With that code running when I hit the button, it does nothing. If I remove the if and it’s just

on (release){

```
        gotoAndPlay(5);
        }

```

it runs fine, but once I add in the if with the variable check it doesn’t work anymore. Am I declaring it or assigning the value incorrectly?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2004, 5:32pm UTC](https://forum.kirupa.com/t/flash-mx-variable-problem/57434/4 "2004-07-14T17:32:17Z")

</div>

ur missing a closing parenthesis:

```auto
on (release){
if (gateStat == 0) {
gotoAndPlay(5);
}

```

should be:

```auto
 on (release){
if (gateStat == 0) {
gotoAndPlay(5);
}
**}**

```

regards,

Prophet.
