# Global Variable Undefined

**URL:** https://forum.kirupa.com/t/global-variable-undefined/57838
**Category:** flash
**Created:** [July 16, 2004, 3:44pm UTC](https://forum.kirupa.com/t/global-variable-undefined/57838 "2004-07-16T15:44:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![strivedi](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@strivedi](https://forum.kirupa.com/u/strivedi)
#### Post date: [July 16, 2004, 3:44pm UTC](https://forum.kirupa.com/t/global-variable-undefined/57838/1 "2004-07-16T15:44:58Z")

</div>

Hi folks, here is the set up. I’m working with three files. Main.swf which contains navigation.swf in a blankmc, empty mc called mcContent where navigation sleclected materials are loaded.

In the navigation.fla here is the code  
[AS]trace(“now defining global”);  
\_global.loadFile\_str = strPicName;  
trace(“global defined as”);

```
	trace(_global.loadFile_str);

```

\_root.mcContent.loadMovie(“monthlyreports.swf”);  
[/AS]  
which leads to the trace results of…  
[AS]now defining global  
global defined as  
images/cbookings.jpg  
[/AS]

when i do a trace of loadFile\_str in the first frame of monthlyreports i get a undefined. I have tried trace(loadFile\_str) and trace(\_global.loadFile\_str)

I also noticed that if i define the global on the main movie ( it maintains the global variable, the navigation fla will not overwrite it) not sure if that helps anything but i thought i let you know.

Thanks for any help.

---

<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 17, 2004, 9:21am UTC](https://forum.kirupa.com/t/global-variable-undefined/57838/2 "2004-07-17T09:21:33Z")

</div>

Hi,  
It works for me.  
i’ve made a movie called navigation.swf and other monthlyreports.swf (as yours =) ) as follows…

```auto
// first frame in **navigation.swf**
trace("now defining global");
_global.loadFile_str = "strPicName";
trace("global defined as "+_global.loadFile_str);
this.loadMovie("monthlyreports.swf");

```

and…

```auto
// first frame in **monthlyreports.swf**
trace(loadFile_str+" (located in external swf)");

```

Output window displays…

```auto
now defining global
global defined as strPicName
strPicName (located in external swf)

```

…and all works fine 😉

sample files below…

---

<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 17, 2004, 1:33pm UTC](https://forum.kirupa.com/t/global-variable-undefined/57838/3 "2004-07-17T13:33:32Z")

</div>

Thanks PCMan,

Maybe it was a bugish kind of a thing. Its not the first time i’ve had something work in one file and not in others. I’ll give your files a shot and hopefully it works!

Thanks again

---

<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 17, 2004, 5:44pm UTC](https://forum.kirupa.com/t/global-variable-undefined/57838/4 "2004-07-17T17:44:14Z")

</div>

heres a thought…  
i got the impression you were trying to set the global variable to a local variable called _strPicName_…  
does _strPicName_ actually have a value??  
meh… just a thought 😉

Prophet.

---

<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 28, 2004, 2:43pm UTC](https://forum.kirupa.com/t/global-variable-undefined/57838/5 "2004-07-28T14:43:06Z")

</div>

Prophet: yes strPicName has a value something like “home.xml”

PCMan: You attached .swf’s and not .fla’s so I can’t see it working as I want it to.

I still have the problem. Anyone have anyother suggestions? Here is the latest info…3 files. Home, Nav, Content

Home AS Code:  
[AS]if (\_global.loadFile\_str == undefined) {  
trace(“default aboutus”)  
\_global.loadFile\_str = “aboutus.xml”;  
}  
\_root.mcContent.loadMovie(“content.swf”);  
\_root.mcNav.loadMovie(“navigation.swf”);[/AS]

Nav AS Code:  
[AS]Actions.ldmovie = function(strFilePathName){  
\_global.loadFile\_str = strFilePathName;  
\_root.mcContent.loadMovie(“content.swf”);  
trace("nav: " + \_global.loadFile\_str);  
};[/AS]

Content AS Code:

[AS]trace("Content: " + loadFile\_str);[/AS]

Trace output :  
[AS]default aboutus  
Content: aboutus.xml  
nav: directions.xml  
Content: aboutus.xml[/AS]

---

<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 30, 2004, 3:05pm UTC](https://forum.kirupa.com/t/global-variable-undefined/57838/6 "2004-07-30T15:05:31Z")

</div>

bump
