Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable access problems

Status
Not open for further replies.

frozenpeas

Technical User
Sep 13, 2001
893
CA
Hey, I am trying to set a global variable then call it from loaded movies. It seems that I am not able to access the variable from the loaded movies.

Here is where I'm setting the variable (which it does successfully):

Code:
fscommand("showmenu", 0);
fscommand("allowscale", 0);
#include "xmlnitro.as"
configfile = new XML();
configfile.onLoad = readXML;
configfile.load('/config.xml');
function readXML () {
    if (configfile.loaded) {
        for (i=0; i<configfile.childNodes[2].childNodes.length; i++) {
            node = configfile.childNodes[2].childNodes[i];
            if (node.nodeName.toLowerCase() == &quot;season&quot;) {
                _global.season = node.childNodes;
            }
        }
		bg = &quot;/&quot;+season+&quot;/bg.swf&quot;;
		menu = &quot;/&quot;+season+&quot;/menu.swf&quot;;
		loadMovieNum(bg, 1);
		loadMovieNum(menu, 3);
    } else {
        readXML();
    }
}

and here is how I'm calling it from the loaded movies:

Code:
bg = &quot;/&quot;+season+&quot;/bg.jpg&quot;;
loadMovie(bg,&quot;_root.blank&quot;);
home = &quot;/&quot;+season+&quot;/home.swf&quot;;
loadMovieNum(home, 1);

When I replace season with something else (valid folder name) it works.

Thanks.

 
use _root.season instead of _global.season
use _root.season instead of season
wherever you refer that variable use _root.season

generally refer all your variables as _root variables if you want them to be seen everywhere. Diana.
icq: 111872918
 
That's not really correct, but thanks for the response.
 
Looks like &quot;_global&quot; only works for the movie it's declared in (the documentation cerainly points to this although it's not all that clear), so from other movies you would have to access it via the level it's been loaded into: _level0.season

P.S. xml.nitro isn't necessary in MX as they've incorporated the code as standard, or is this a new version that I don't know about? If so, where'd ya get it? ;-)
 
Thanks, wangbar.

On my first attempt I actually used _level0.season but got the same (non)result.

As for xmlnitro, I didn't realize that that code had been worked into MX.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top