View Full Version : [AS2] Duplicate movie based on array data

05-16-2012, 07:03 PM
Hello flash enthusiasts,

I am currently building a (mock up) to view subscriber information by duplicating a movie clip based on an array. I'm grabbing the data from an xml and trying to pass the array to duplicated clips. The problem I'm running into is that I can only get data to the first duplicated movie and the original remains blank.

Here is the xml:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<addressid>1111 First St</addressid>
<cityid>Los Angeles</cityid>
<addressid>2222 Second St</addressid>
<cityid>San Francisco</cityid>

Here is how I'm loading the xml:

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
last4id = [];
fnameid = [];
lnameid = [];
expdate = [];
addressid = [];
cityid = [];
stateid = [];
zipid = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
last4id[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
fnameid[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
lnameid[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
expdate[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
addressid[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
cityid[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
stateid[i] = xmlNode.childNodes[i].childNodes[6].firstChild.nodeValue;
zipid[i] = xmlNode.childNodes[i].childNodes[7].firstChild.nodeValue;
} else {
trace("Can not load edit card xml");
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;

And on the next frame I'm running a for loop:

for (i=1; i<total; ++i) {
item_mc.info_mc.duplicateMovieClip("info_mc"+i, i);
item_mc["info_mc"+i]._y = item_mc["info_mc"+i]._height+15;
item_mc["info_mc"+i].fname.text = fnameid[i];
item_mc["info_mc"+i].lname.text = lnameid[i];
item_mc["info_mc"+i].cdigits.text = last4id[i];
item_mc["info_mc"+i].cdate.text = expdate[i];
item_mc["info_mc"+i].caddress.text = addressid[i];
item_mc["info_mc"+i].ccity.text = cityid[i];
item_mc["info_mc"+i].cstate.text = stateid[i];
item_mc["info_mc"+i].czip.text = zipid[i];

I'm wondering if I'm missing an initial load step or that I'm not splitting the array correctly.

Any and all help is greatly appreciated and thank you for taking a moment to look at this post.