Global Vars

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]