Hey all,
I want to create variables using the length of an XML childnode as the iterator. I would like to create vars named: snd1, snd2, snd3…and so on.
My AS code is:
[AS]
//---------------------------------------------------
//XML addition of external data
//---------------------------------------------------
var templateXML:XML = new XML();
templateXML.ignoreWhite = true;
templateXML.load(“safety.xml”);
templateXML.onLoad = function(p_success:Boolean):Void
{
if(p_success)
{
//Working on the sound array in the XML file.
var xmlLen =templateXML.firstChild.childNodes[0].childNodes.length;
for(i = 1; i < xmlLen + 1; i++)
{
//trace(i + " worked.");
snd* = "Sound " + i;
trace(snd*);
}
}
}
[/AS]
My XML file is:
<assets>
<audios>
<audio path=“audio/audio1.wav”/>
<audio path=“audio/audio2.wav”/>
<audio path=“audio/audio3.wav”/>
<audio path=“audio/audio4.wav”/>
<audio path=“audio/audio5.wav”/>
<audio path=“audio/audio6.wav”/>
<audio path=“audio/audio7.wav”/>
<audio path=“audio/audio8.wav”/>
<audio path=“audio/audio9.wav”/>
<audio path=“audio/audio10.wav”/>
</audios>
</assets>
I don’t know why I am getting an ‘undefined’ when I try to trace out the variable value.
Any help is appreciated.