I have an XML file that has a large group of buttons. (ex below)
code:
<unitedstates>
<state name="WA">
<enabled>1</enabled>
<bordercolor>3F3F3F</bordercolor>
<color>336699</color>
<url>http://www.hotmail.com</url>
</state>
<state name="OR">
<enabled>1</enabled>
<bordercolor>3F3F3F</bordercolor>
<color>336699</color>
<url>http://www.gmail.com</url>
</state>
</unitedstates>


I want to be able to dynamically have each of those buttons go to the URL I specified in the <url></url> tag.

This is the code that I am trying to do as I loop through the XML file, but it's assigning it onrelease. I want to assign it at the beginning.

code:

for(var i = 0; i < xmlDoc_xml.firstChild.childNodes.length; i++){
var strURL = xmlDoc_xml.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue;
eval(stateName).onRelease = function(){
trace(strURL);
getURL(strURL, "_self");
}
}



the problem with this is that it assigns the last URL in the XML file to the every button I click on. So in this instance, the WA button AND the OR button will both go to gmail.com because that's the last one it was assigned to.

How do I add the right URL to the right button in that loop and have it stick?

Thanks.