# Frustrated about \_global and scope of variables

**URL:** <https://forum.kirupa.com/t/frustrated-about--global-and-scope-of-variables/14664>\
**Category:** flash\
**Created:** [March 1, 2003, 1:41am UTC](https://forum.kirupa.com/t/frustrated-about--global-and-scope-of-variables/14664 "2003-03-01T01:41:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cadmiumgreen](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@cadmiumgreen](https://forum.kirupa.com/u/cadmiumgreen)\
**Post date:** [March 1, 2003, 1:41am UTC](https://forum.kirupa.com/t/frustrated-about--global-and-scope-of-variables/14664/1 "2003-03-01T01:41:08Z")

</div>

Hello forum,

I’m starting out in ActionScript for Flash MX, got done with a few chapters in ActionScript for Flash MX by Colin Moock and I have a few frustrating problems.

#1)  
I created a square, defined as a movie clip symbol (named square), placed it on the main timeline and made an instance of it called mySquare.

Now, I want to create a global variable that is directly accessible to all the scripts in a movie (any timeline). And I want the global variable to be declared and initialized in the movie clip symbol (named square).

So I put the following code on frame 1 of the ‘square’ movie clip timeline:

\_global.day = “Monday”; //Moock’s book - page 50.

Then I placed the following code on frame 1 of the main movie:

trace(day);

According to Moock’s book, it says that because the ‘day’ variable is global, Flash MX can find it from the main timeline, even though it was created in the ‘square’ movie clip.

When I test the movie, the output window displays:

undefined

Why is it still displaying ‘undefined’.

Your help and assistance is GREATLY appreciated!!

Sincerely,  
byron m.  
cadmiumgreen

---

<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:** [March 1, 2003, 1:55am UTC](https://forum.kirupa.com/t/frustrated-about--global-and-scope-of-variables/14664/2 "2003-03-01T01:55:36Z")

</div>

hey cadmiumgreen 🙂

scripts in the main timeline are executed before the scripts in the movie clips. so actually nothing is wrong :-\

when this action **trace(day);** is executed technically **day** doesn’t exist

try this:

```auto
trace(day);
t = function () {
	trace(day);
	clearInterval(ti);
}
ti = setInterval(t, 1000);

```

the first time will output undefined  
the second time it should be ok

=)
