Duplicate Button Dynamically

Hey folks,

My last few posts on this topic aren’t getting replies but I’ve solved a few things and I hope this isn’t too tricky.

I am reading in a XML file that contains menu items, then assigning the values of each node to a button. I created a button called “btn” and have figured out how to duplicate it but I am having problems assigning AS to each button. I also have a dynamic text field called link in the button where I want to assign it a name (See the line in red), any ideas?


for (child = 0; child < count; child++)
{
currentLocation = LocationTag.childNodes[child];
nameArray[child] = currentLocation.attributes.name;
urlArray[child] = currentLocation.attributes.url;
descriptionArray[child] = currentLocation.attributes.GalleryDescription;
			
duplicateMovieClip ("btn", "btn" + child, child);
setProperty ("btn" + child, _y, 170 + child*20);
setProperty ("btn" + child, _x, 190 + child*0);
[COLOR=Red]_root["btn" + child].link = nameArray[child];[/COLOR]
[COLOR=Navy]**this["btn"+child].onRelease = function(){
	_root.contents.loadMovie(nameArray[child]);
};**[/COLOR] // [COLOR=Green]This does nothing, what is wrong?[/COLOR]
}
setProperty("btn", _visible, 0);


Basically, I want every button to have code like this.
on (release) {
_root.contents.loadMovie(“nameArray variable”);
}

Ok, I hope this makes sense. Thanks for reading
Brian