Load different XML files with different buttons

Hello All.

Trying to make a multi-lingual flash application.

First Frame has Different language btns and I’d like to load the XML file desired by hitting the buttons.
After hours of searching online I managed to find this code in a thread but I’m getting undefined file name.
Little new to XML if someone can see my error or has an alternative option for me would be greatly appreciated.

var myXML:XML = new XML;
myXML.load(xmlFile);
myXML.ignoreWhite = true;
loadXMLfunc.onLoad = function(ok:Boolean):Void

{
if (ok)
{
menu_title.text=myXML.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
menu_game.text=myXML.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
menu_game2.text=myXML.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
menu_game3.text=myXML.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
gotoAndStop(2);
}
}

/******************************************/

eng_btn.onRelease = function() {
xmlFile = “english.xml”;
loadXMLfunc();
}

fr_btn.onRelease = function() {
xmlFile = “french.xml”;
loadXMLfunc();
}
}
sp_btn.onRelease = function() {
xmlFile = “spanish.xml”;
loadXMLfunc();
}
}

Thanks in Advance!


var myXML:XML = new XML();
myXML.ignoreWhite = true;
loadXMLfunc.onLoad = function(ok:Boolean):Void 
{
    if (ok)
    {
        menu_title.text = myXML.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        menu_game.text = myXML.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        menu_game2.text = myXML.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
        menu_game3.text = myXML.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
        gotoAndStop(2);
    }
};


eng_btn.onRelease = function()
{
    myXML.load("english.xml");
};

fr_btn.onRelease = function()
{
    myXML.load("french.xml");
};

sp_btn.onRelease = function()
{
    myXML.load("spanish.xml");
};

Nice One! Thanks man. That photo truly says MrWicked!

Well it’s calling the xml files fine now but I’m not getting the frame change. Should I add a preloader in here?

hmm thats weird try using ‘success’ rather than ok and remove the boolean property…Are the other actions in that if(ok) working?

Thanks for your time on this man appreciated!

so now I’ve tried

loadXMLfunc.onLoad = function(success){
if (success) {

     menu_title.text=myXML.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue; menu_game.text = myXML.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;

menu_game2.text = myXML.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
menu_game3.text = myXML.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue ;
}
}

I took away the gotoAndPlay(2) command and put some text boxes on the first frame and still getting nothing, not even undefined. Hmm back to the drawing board on this one. Should I put everything in an array?

loadXMLfunc.onLoad = function(ok:Boolean):Void

Shouldn’t that be myXML.onLoad?

[quote=takethetrain;2348876]

loadXMLfunc.onLoad = function(ok:Boolean):Void

Shouldn’t that be myXML.onLoad?[/quote]

yup you’re right.

loadXMLfunc.onLoad = function(ok:Boolean):Void
this was what I had before. Regardless I’ve changed it back to

loadXMLfunc.onLoad = function(ok:Boolean):Void {
if (ok) {

menu_title.text = myXML.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
menu_game.text = myXML.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
menu_game2.text = myXML.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
menu_game3.text = myXML.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue ;
gotoAndPlay(2);
}
}
Still getting no results…hmm seem to think it’s back to the first question as this set up works fine if I call a file directly ie myXML.load(“english.xml”); as opposed to calling it from a button.
Either that or I need to rework the array of text to load. I’m not getting anything with the trace() but it’s not telling me undefined file or that it can’t find the file or anything like that either.
Thanks for help on this.

Thanks again for the help with this.
Managed to get it to work by
adding the gotoAndPlay(2); directly to the button
and then on frame2 adding onEnterFrame = function() { with the nodes I wanted to load where.

Cheers again for your time now I got to put this thing together!