# Load different XML files with different buttons

**URL:** <https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302>\
**Category:** flash\
**Created:** [June 24, 2008, 8:41pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302 "2008-06-24T20:41:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 24, 2008, 8:41pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/1 "2008-06-24T20:41:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 24, 2008, 10:59pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/2 "2008-06-24T22:59:22Z")

</div>

```auto

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");
};

```

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 25, 2008, 1:01am UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/3 "2008-06-25T01:01:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 25, 2008, 1:39am UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/4 "2008-06-25T01:39:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 25, 2008, 4:45am UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/5 "2008-06-25T04:45:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 25, 2008, 11:15am UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/6 "2008-06-25T11:15:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![takethetrain](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@takethetrain](https://forum.kirupa.com/u/takethetrain)\
**Post date:** [June 25, 2008, 3:25pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/7 "2008-06-25T15:25:03Z")

</div>

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

```

Shouldn’t that be myXML.onLoad?

---

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [June 25, 2008, 3:55pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/8 "2008-06-25T15:55:19Z")

</div>

[quote=takethetrain;2348876]

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

```

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

yup you’re right.

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 25, 2008, 6:33pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/9 "2008-06-25T18:33:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cortezcreations](https://avatars.discourse-cdn.com/v4/letter/c/b782af/32.png) [@cortezcreations](https://forum.kirupa.com/u/cortezcreations)\
**Post date:** [June 26, 2008, 2:21pm UTC](https://forum.kirupa.com/t/load-different-xml-files-with-different-buttons/264302/10 "2008-06-26T14:21:06Z")

</div>

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!
