Duplicate movie based on array data
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:
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<content>
<article>
<last4id>1111</last4id>
<fnameid>fname1</fnameid>
<lnameid>lname1</lnameid>
<expdate>11/11</expdate>
<addressid>1111 First St</addressid>
<cityid>Los Angeles</cityid>
<stateid>CA1</stateid>
<zipid>11111</zipid>
</article>
<article>
<last4id>2222</last4id>
<fnameid>fname2</fnameid>
<lnameid>lname2</lnameid>
<expdate>22/22</expdate>
<addressid>2222 Second St</addressid>
<cityid>San Francisco</cityid>
<stateid>CA2</stateid>
<zipid>22222</zipid>
</article>
</content>
Here is how I'm loading the xml:
Code:
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;
}
nextFrame();
} else {
trace("Can not load edit card xml");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("edittest.xml");
And on the next frame I'm running a for loop:
Code:
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.
Thanks,
Kumba
One more quick question...
So now that I have the clips duplicated, how would I access individual instances of buttons within each clip?
So if I have a button called "edit_btn" in each duplicate. I can access the object path with an onRelease (in the 'for' loop) using a trace which returns:
Code:
_level0.content_mc.billing.item_mc.info_mc0.edit_btn
I thought of converting the object path to a string and using "charAt" but wasn't too successful.
What I'm trying to do is get the duplicate movie number (info_mc0) so I can use it to reference the xml array that needs to be edited.
Make sense?
LOLOLOL! I feel like I'm explaining this in a "loop" :faded: