PDA

View Full Version : Global Variable Undefined



strivedi
July 16th, 2004, 11:44 AM
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
trace("now defining global");
_global.loadFile_str = strPicName;
trace("global defined as");

trace(_global.loadFile_str);
_root.mcContent.loadMovie("monthlyreports.swf");

which leads to the trace results of...
now defining global
global defined as
images/cbookings.jpg


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.

pcMan
July 17th, 2004, 05:21 AM
Hi,
It works for me.
i've made a movie called navigation.swf and other monthlyreports.swf (as yours =) ) as follows...
// 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....

// first frame in monthlyreports.swf
trace(loadFile_str+" (located in external swf)");
Output window displays....
now defining global
global defined as strPicName
strPicName (located in external swf)

...and all works fine ;)

sample files below...

strivedi
July 17th, 2004, 09:33 AM
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

Prophet
July 17th, 2004, 01:44 PM
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.

strivedi
July 28th, 2004, 10:43 AM
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:
if (_global.loadFile_str == undefined) {
trace("default aboutus")
_global.loadFile_str = "aboutus.xml";
}
_root.mcContent.loadMovie("content.swf");
_root.mcNav.loadMovie("navigation.swf");

Nav AS Code:
Actions.ldmovie = function(strFilePathName){
_global.loadFile_str = strFilePathName;
_root.mcContent.loadMovie("content.swf");
trace("nav: " + _global.loadFile_str);
};

Content AS Code:

trace("Content: " + loadFile_str);

Trace output :
default aboutus
Content: aboutus.xml
nav: directions.xml
Content: aboutus.xml

strivedi
July 30th, 2004, 11:05 AM
bump