# Won't read variable

**URL:** <https://forum.kirupa.com/t/wont-read-variable/38426>\
**Category:** Uncategorized\
**Created:** [December 22, 2003, 8:00pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426 "2003-12-22T20:00:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandman9](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sandman9](https://forum.kirupa.com/u/Sandman9)\
**Post date:** [December 22, 2003, 8:00pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/1 "2003-12-22T20:00:20Z")

</div>

I have a MC on my stage. It has let’s say a motion tween that covers the stage when you click on a button. At the end of this motion tween we have a loadMovie (it loads a external swf). Then after that we have another motion tween that reveals the stage this time (showing the new swf)

My problem is that I don’t want the animation in the swf to start until the motion tween that reveals the stage is complete.

so what i did was at the end of the motion tween that reveals the stage i put

```auto

_global.myFlag=3;

```

then in the first frame the of movie being loaded i put

```auto

stop();
if (myFlag==3) {
    blah blah ...
}

```

this does not work … anyone know of a different way or why this is not working?

Cheers  
Sandman9

---

<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:** [December 22, 2003, 8:36pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/2 "2003-12-22T20:36:23Z")

</div>

:h:

```auto

stop();
if (_global.myFlag==3) {
        blah blah ...
}

```

---

<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:** [December 22, 2003, 10:01pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/3 "2003-12-22T22:01:46Z")

</div>

blah blah is the rest of my script … for example … gotoandPlay(“begin”); … so this tells it to play the movie when myFlag=3 except it does not play

Sandman9

---

<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:** [December 22, 2003, 10:30pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/4 "2003-12-22T22:30:57Z")

</div>

Just a wild guess…  
[AS]stop();  
m = \_parent.createEmptyMovieClip(“temp”, 1000);  
m.onEnterFrame = function(){  
if(\_global.myFlag==3) {  
blah blah … ;  
delete this.onEnterFrame;  
}  
}[/AS]

scotty(-:

---

<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:** [December 22, 2003, 10:44pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/5 "2003-12-22T22:44:11Z")

</div>

thanks for the reply’s

Scotty, I do not see how this is applicable? did you read the first post?

If anythings unclear then please let me know

Cheers  
Sandman9

---

<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:** [December 22, 2003, 10:52pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/6 "2003-12-22T22:52:49Z")

</div>

Put it on the first frame of the movie being loaded. Your way it’s only checking once, mine keeps on checking till it’s true (at least that is what it should do, i didn’t test it)

scotty(-:

---

<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:** [December 22, 2003, 11:34pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/7 "2003-12-22T23:34:35Z")

</div>

Hello Scotty

I have a preloader script on the first frame of the movie being loaded … so what i did using your script was

```auto

this.onEnterFrame = function() {
	//checks to see if the external movie (this) is fully loaded
	if (this.getBytesLoaded()<this.getBytesTotal()) {
		Total = this.getBytesTotal()/1000;
		Received = this.getBytesLoaded()/1000;
		_root.cover.loader.percentage = (Received/Total)*100;
		//tell the progress bar animation (located in the cover mc)
		//to go to a frame between 0 and 100
		_root.cover.loader.bar._xscale = percentage;
	} else {
		//when its fully loaded
		m = _parent.createEmptyMovieClip("temp", 1000);
        m.onEnterFrame = function(){
        if(_global.myFlag==3) {
                gotoAndPlay(2);
                delete this.onEnterFrame;
        }
}
		//tell the cover mc to play its opening animation
		_root.cover.gotoAndPlay("show_mc");
		//turn of the enterFrame action
		this.onEnterFrame = null;
	}
};
stop();

```

This worked BUT if i click on a different button and then click on the button that loads this same swf again then the animation starts without waiting for the motion tween to finish.

I don’t know if this helps but it’s not exactly a motion tween revealilng the stage. I have a MC that is being attached and then duplicated to cover the stage area. Then in this MC it has a motion tween that reveals part of the stage (at the end of this motion tween i have “\_global.myFlag=3;”

Sandman9

---

<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:** [December 23, 2003, 8:30am UTC](https://forum.kirupa.com/t/wont-read-variable/38426/8 "2003-12-23T08:30:26Z")

</div>

I see, it doesn’t work the second time, because myFlag is set to 3. So after you run it the first time you have to reset myFlag. Try:[AS] m = \_parent.createEmptyMovieClip(“temp”, 1000);  
m.onEnterFrame = function(){  
if(\_global.myFlag==3) {  
gotoAndPlay(2);  
\_global.myFlag = null;  
delete this.onEnterFrame;  
}[/AS]

scotty:?)

---

<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:** [December 23, 2003, 10:39am UTC](https://forum.kirupa.com/t/wont-read-variable/38426/9 "2003-12-23T10:39:48Z")

</div>

To read a global variable, you don’t have to place \_global in front, only to write them.

---

<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:** [December 23, 2003, 10:53am UTC](https://forum.kirupa.com/t/wont-read-variable/38426/10 "2003-12-23T10:53:04Z")

</div>

Thanks Voetsjoeba, I know;)  
With copy and paste it just stayed there…

scotty:?)

---

<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:** [December 23, 2003, 6:39pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/11 "2003-12-23T18:39:59Z")

</div>

Scotty

that seems logical but it did not work … when i click on anothr button and then come back to this one it starts to play before the revealing animation is done … ummmmm

Voetsoeba  
I didn’t get what you meant by “only to write them”

Thanks guys  
Sandman9

---

<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:** [December 23, 2003, 6:50pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/12 "2003-12-23T18:50:23Z")

</div>

I GOT IT!!! … i just went in and added

\_global.myFlag = null;

before the loadMovie command … thanks for all the help Scotty

Sandman9

---

<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:** [December 23, 2003, 6:56pm UTC](https://forum.kirupa.com/t/wont-read-variable/38426/13 "2003-12-23T18:56:23Z")

</div>

Pfff, I just wanted to reply to you that I didn’t understand it anymore:D  
Good that you worked it out!

scotty(-:
