# Variable-Bracket Notation-Loops...killing me

**URL:** <https://forum.kirupa.com/t/variable-bracket-notation-loops-killing-me/218966>\
**Category:** Uncategorized\
**Created:** [March 12, 2007, 8:41pm UTC](https://forum.kirupa.com/t/variable-bracket-notation-loops-killing-me/218966 "2007-03-12T20:41:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lariat1997](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@lariat1997](https://forum.kirupa.com/u/lariat1997)\
**Post date:** [March 12, 2007, 8:41pm UTC](https://forum.kirupa.com/t/variable-bracket-notation-loops-killing-me/218966/1 "2007-03-12T20:41:26Z")

</div>

Hey all,

I have taken a bottle of Excedrin due to the headache I’ve developed from this problem I am having. I have some variables:  
[AS]  
var snd1:Sound = new Sound(this);  
var snd2:Sound = new Sound(this);  
var snd3:Sound = new Sound(this);  
var snd4:Sound = new Sound(this);  
var snd5:Sound = new Sound(this);  
var snd6:Sound = new Sound(this);  
var snd7:Sound = new Sound(this);  
var snd8:Sound = new Sound(this);  
var snd9:Sound = new Sound(this);  
var snd10:Sound = new Sound(this);  
var snd11:Sound = new Sound(this);  
var snd12:Sound = new Sound(this);  
var snd13:Sound = new Sound(this);  
[/AS]  
And I do not want to hard-coded them, but increment via length from an XML childNode.

My code:  
[AS]  
var snd:Array = [];  
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.  
xmlLen = templateXML.firstChild.childNodes[0].childNodes.length;

```
	_Vars();
}

```

}

function \_Vars()  
{  
trace("xmlLen value is: " + xmlLen);

```
for(i = 1; i &lt; xmlLen; i++)
{

	var snd*:Sound = new Sound(snd*);
	trace(snd*);
}		

```

}  
[/AS]  
Is giving me errors. Any help on solving this would be greatly appreciated. Again, I would like to create variables based on the length of a childNode. The first part of the code from this post is what is current, the 2nd parts if kinda where I want it to go.

Thanks.
