Hi all, I have come with another question for your Flash...all...knowingness...
I have a loop that reads some data from an XML file, and uses that to create a group of movieclips. Below is my code.
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
tempclip = attachMovie("Gallery_mc", "Index.gallery"+i, 100,{_x:292, _y
143+(i*103)), captxt:xmlNode.childNodes.childNodes[1].firstChild.nodeValue});
createEmptyMovieClip([tempclip].image, 150);
loadMovie (xmlNode.childNodes.childNodes[0].firstChild.nodeValue, Index_mc.gallery1.image)
setProperty ([tempclip].image, _x, 25)
setProperty ([tempclip].image, _y, (50+(i*103)))
}
} else {
trace ("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("photogallery.xml");
Now you can probably see my problem... when I run this loop, the tempclip variable overwrites the previous tempclip.
The purpose of my clip is to dynamically create a group of movieclips, each one below the one before it.
My question is, how can I change the name of the tempclip variable? You know, so that the first time it runs it is like tempclip0, the second time is tempclip1, etc. Or should I use an array of clips? (By the way, how would I declare an array like that?)
If you can see a better way for me to do this, please, let me know.
Thanks for your help!
I have a loop that reads some data from an XML file, and uses that to create a group of movieclips. Below is my code.
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
tempclip = attachMovie("Gallery_mc", "Index.gallery"+i, 100,{_x:292, _y
createEmptyMovieClip([tempclip].image, 150);
loadMovie (xmlNode.childNodes.childNodes[0].firstChild.nodeValue, Index_mc.gallery1.image)
setProperty ([tempclip].image, _x, 25)
setProperty ([tempclip].image, _y, (50+(i*103)))
}
} else {
trace ("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("photogallery.xml");
Now you can probably see my problem... when I run this loop, the tempclip variable overwrites the previous tempclip.
The purpose of my clip is to dynamically create a group of movieclips, each one below the one before it.
My question is, how can I change the name of the tempclip variable? You know, so that the first time it runs it is like tempclip0, the second time is tempclip1, etc. Or should I use an array of clips? (By the way, how would I declare an array like that?)
If you can see a better way for me to do this, please, let me know.
Thanks for your help!