# Global Vars

**URL:** https://forum.kirupa.com/t/global-vars/94533
**Category:** Uncategorized
**Created:** [November 13, 2003, 5:33pm UTC](https://forum.kirupa.com/t/global-vars/94533 "2003-11-13T17:33:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lbeetles](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@lbeetles](https://forum.kirupa.com/u/lbeetles)
#### Post date: [November 13, 2003, 5:33pm UTC](https://forum.kirupa.com/t/global-vars/94533/1 "2003-11-13T17:33:32Z")

</div>

Hi All,

I have this code in a movie, the movie loads fine on it’s own but when i load it into another movie it does not work.

I think this is to do with global vars, but im not sure.

Could someone please have a look at the code to see if it is the case. If it is could someone please show me how and where i would change the vars so they are global vars.

Here is the script.  
[AS]  
//--------------------------------------------------------------------------------  
//XML ONLOAD EVENT - INVOKED WHEN XML IS LOADED  
//--------------------------------------------------------------------------------  
function onImgLoaded(success) {  
if (success) {  
mainTag = new XML();  
mainTag.ignoreWhite = true;  
for (var i = 0; i\<this.childNodes.length; i++) {  
if (this.childNodes\*.nodeValue == null && this.childNodes\*.nodeName.toLowerCase() == “comboitems”) {  
mainTag = this.childNodes\*;  
}  
}  
delete imgXML;  
arrImgXML02 = [];  
var item = 0;  
for (var i = 0; i\<mainTag.childNodes.length; i++) {  
if (mainTag.childNodes\*.nodeName != null) {  
arrImgXML02[item] = {};  
for (var j = 0; j\<mainTag.childNodes\*.childNodes.length; j++) {  
var itemName = mainTag.childNodes\*.childNodes[j];  
if (itemName.nodeName == “code”) {  
arrImgXML02[item].code = itemName.firstChild.nodeValue;  
}  
if (itemName.nodeName == “description”) {  
arrImgXML02[item].label = itemName.firstChild.nodeValue;  
}  
if (itemName.nodeName == “groupimage”) {  
arrImgXML02[item].groupImg = itemName.firstChild.nodeValue;  
}  
}  
item++;  
}  
}  
delete mainTag;  
imgXML\_lb.setDataProvider(arrImgXML02);  
} else {  
trace(“no XML loaded”);  
}  
}  
//--------------------------------------------------------------------------------  
// ONLOAD EVENT CALLBACK INVOKED WHEN TEXT IS LOADED  
//--------------------------------------------------------------------------------  
function onTextLoaded(success) {  
if (success) {  
\_root.text\_field.htmlText = this.imgText;  
} else {  
\_root.text\_field.text = “sorry, there seems to be a problem and text could not be loaded”;  
}  
}  
//--------------------------------------------------------------------------------  
// CHANGEHANDLER FOR LISTBOX - LOADS IMAGE INTO SCROLLPANE  
//--------------------------------------------------------------------------------  
function handleImg(\_lb) {  
var img = \_lb.getSelectedItem().groupImg;  
xmlImg\_sp.loadScrollContent(img);  
}  
//--------------------------------------------------------------------------------  
// INITIALIZE MOVIE… LOAD TEXT, XML,  
//--------------------------------------------------------------------------------  
if (!inited) {  
inited = true;  
text\_field.background = true;  
text\_field.backgroundColor = 0x909090;  
text\_field.border = true;  
text\_field.borderColor = 0x666666;  
//  
imgXML\_lb.setAutoHideScrollBar(true);  
//  
var imgXML = new XML();  
imgXML.ignoreWhite = true;  
imgXML.onLoad = onImgLoaded;  
imgXML.load(“image.xml”);  
}  
stop();  
[/AS]
