# Duplicate movieclips: Array within an array

**URL:** <https://forum.kirupa.com/t/duplicate-movieclips-array-within-an-array/249251>\
**Category:** flash\
**Created:** [January 16, 2008, 10:42pm UTC](https://forum.kirupa.com/t/duplicate-movieclips-array-within-an-array/249251 "2008-01-16T22:42:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JTrest](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@JTrest](https://forum.kirupa.com/u/JTrest)\
**Post date:** [January 16, 2008, 10:42pm UTC](https://forum.kirupa.com/t/duplicate-movieclips-array-within-an-array/249251/1 "2008-01-16T22:42:24Z")

</div>

Hello.  
Having a problem with duplicating movieclips within an array within another array.  
I’m trying to setup a horizontal categorical menu drawn from an xml file.

I want this:

0  
mainMenuSmall0.jpg  
1  
mainMenuSmall1.jpg  
2  
mainMenuSmall2.jpg

…etc.

The following is the code:

var array = new Array ();  
var xml = new XML ();  
xml.onLoad = function ()  
{  
var header, link, image;  
for (var i = 0; i \< this.firstChild.childNodes.length; i++)  
{  
if (this.firstChild.childNodes\*.nodeName != null)  
{  
header = this.firstChild.childNodes\*.attributes.header;  
}  
for (var j = 0; j \< this.firstChild.childNodes\*.childNodes.length; j++)  
{  
if (this.firstChild.childNodes\*.childNodes[j].nodeName == “link”)  
{

link = this.firstChild.childNodes\*.childNodes[j].firstChild.nodeValue;  
}  
}  
for (var k = 0; k \< this.firstChild.childNodes\*.childNodes.length; k++)  
{  
if (this.firstChild.childNodes\*.childNodes[k].nodeName == “image”)  
{

image = this.firstChild.childNodes\*.childNodes[k].firstChild.nodeValue;  
}  
}  
array.push (new struct (header, link, image));  
}  
printer ();  
};  
xml.load (“dbase.xml”);

function printer ()  
{  
for (i = 1; i \< array.length; i=i+2)  
{  
slot.duplicateMovieClip ( ‘slot’+i,i,{\_y:100});  
slot.header = array\*.header;  
slot.link = array\*.link;  
slot.image = array\*.image;  
slot = eval ( “slot” + i );  
slot2.duplicateMovieClip ( ‘slot2’+(i+100),i+100,{\_y:50});  
slot2.header = array\*.header;  
slot2.link = array\*.link;  
slot2.image = array\*.image;  
slot2 = eval (“slot2” + (i+100));

}  
}  
function struct (header, link, image)  
{  
this.header = header;  
this.image = image;  
this.link = link;  
}

‘Slot’ and ‘Slot2’ are what the movieclips (blue and green) that should contain the menu item text. I’ve attached the .xml file and the result of what I get when I publish. Essentially the movieclips are not positioning correctly and the only one of each menu item is displaying.

Any advice would be much appreciated.  
Thanks!
