# Duplicate Button Dynamically

**URL:** <https://forum.kirupa.com/t/duplicate-button-dynamically/107324>\
**Category:** Uncategorized\
**Created:** [April 14, 2004, 12:23pm UTC](https://forum.kirupa.com/t/duplicate-button-dynamically/107324 "2004-04-14T12:23:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alwaysdrifting](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@alwaysdrifting](https://forum.kirupa.com/u/alwaysdrifting)\
**Post date:** [April 14, 2004, 12:23pm UTC](https://forum.kirupa.com/t/duplicate-button-dynamically/107324/1 "2004-04-14T12:23:45Z")

</div>

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?

```auto

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
