# \[Flash 8\]XML variable will trace, but will not work in script?

**URL:** https://forum.kirupa.com/t/flash-8-xml-variable-will-trace-but-will-not-work-in-script/245987
**Category:** flash
**Created:** [December 6, 2007, 3:03am UTC](https://forum.kirupa.com/t/flash-8-xml-variable-will-trace-but-will-not-work-in-script/245987 "2007-12-06T03:03:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TomNez](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tomnez/32/1674_2.png) [@TomNez](https://forum.kirupa.com/u/TomNez)
#### Post date: [December 6, 2007, 3:03am UTC](https://forum.kirupa.com/t/flash-8-xml-variable-will-trace-but-will-not-work-in-script/245987/1 "2007-12-06T03:03:42Z")

</div>

Hey all,

I made a button that when you click, it starts to play a sound. The sound is loaded through an XML file. The XML file only has one node which is the path of the sound I want played.

## So I loaded the XML file and made a variable for my sound node and traced it to make sure it worked, and it did. Then later on when I use that variable to make the sound load, it says that there is an error opening url and that the path ends with ‘undefined’. Here’s the whole script:

\*\*load sound:

\*\*stop();  
var myXML:XML = new XML();  
myXML.ignoreWhite = true;  
myXML.onLoad = function(success){  
if(success) {  
for (var x=0;x\<this.firstChild.childNodes.length;x++) {  
var **soundNode** :XMLNode = this.firstChild.childNodes[x];  
trace(soundNode);  
}  
}else{  
//error statement here  
}  
}  
myXML.load(“C:/Documents and Settings/TomNez/Desktop/sound/audio.xml”);

* * *

\*\*And then play sound:  
\*\*  
var mySound:Sound = new Sound();

mySound.loadSound(**soundNode[x]**, true);  
mySound.onSoundComplete = function() {  
this.start();  
};

* * *

The trace statement gives me the right information when I test it. And, if I replace “soundNode[x]” with the actual sound name, it works properly. Does anyone know why it won’t let me use the soundNode variable in my loadSound? Any help would be greatly appreciated.

-Tom
