xml.onLoad variables undefined outside
Hi all,
I've been searching this problem for a while and have tried a number of solutions found on google but nothing has worked so far. I'm sure this is a common problem, but due to my lack of flash knowledge I can't logically work through it as I'm used to windows form development, it makes sense to me that the function could access the variables I have defined but they dissapear after the .onLoad event. Does anyone know the common solution to this problem? I want to be able to pass the xml details into the local variables so I can pass on the details into a dynamic text field when movies are hovered over etc.
var myXML:XML = new XML();
myXML.ignoreWhite=true
var nav1TitleText:String;
var nav1Text:String;
var nav2TitleText:String;
var nav2Text:String;
var nav3TitleText:String;
var nav3Text:String;
var nav4TitleText:String;
var nav4Text:String;
myXML.load("navigation.xml");
myXML.onLoad = function(success){
if (success){
nav1TitleText = myXML.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
trace(nav1TitleText); \\ This one shows the text from the xml file
nav1Text = myXML.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
nav2TitleText = myXML.firstChild.childNodes[1].childNodes[1].firstChild.nodeValue;
nav2Text = myXML.firstChild.childNodes[1].childNodes[2].firstChild.nodeValue;
nav3TitleText = myXML.firstChild.childNodes[2].childNodes[1].firstChild.nodeValue;
nav3Text = myXML.firstChild.childNodes[2].childNodes[2].firstChild.nodeValue;
nav4TitleText = myXML.firstChild.childNodes[3].childNodes[1].firstChild.nodeValue;
nav4Text = myXML.firstChild.childNodes[3].childNodes[2].firstChild.nodeValue;
}
}
trace(nav1TitleText); // This one traces undefined