norfy
09-14-2005, 12:37 PM
I've been searching the site for an answer to this and have inserted some code that people have posted, but it still not quite there. Basically, I wanted to display the same movieclip (a button) on the screen next to each other and then attach different rollover etc functions to each one.
I have created a blank movie clip which I am attempting to attach the multiple movies to (changing the x pos each time). What it is doing is creating the first one, then the second one appears next to it in the right place, but then that disappears and the 3rd one appears it its right place and so on through to the end. So I end up with my first one in place and my last one in place.
I am reading from an xml file to get me the count of the buttons and I'm using a setInterval to delay the output of the buttons on the screen (the idea being they appear one after the other, in a row)
Here is my code:
function xmlLoad(loaded) {
if (loaded) {
xmlNode = this.firstChild;
intNum = intNum;
total = xmlNode.childNodes.length;
catText_arr = [];
catID_arr = [];
for (i=0; i<total; i++) {
catText_arr[i] = xmlNode.childNodes[i].attributes.catText;
catID_arr[i] = xmlNode.childNodes[i].attributes.catid;
}
//create the container movie to attach all other to
attachMovie("boxHolder", boxHolder, 0);
i = 0;
runMovie();
} else {
trace("what xml file");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = xmlLoad;
xmlData.load("xml/images.xml");
function runMovie() {
if (i<=catText_arr.length) {
trace("attach movie"+i);
_root[boxHolder].attachMovie("movie_btn", "movie_btn_"+i+"_mc", this.getNextHighestDepth());
_root[boxHolder]["movie_btn_"+i+"_mc"]._x = 640-28*i;
_root[boxHolder]["movie_btn_"+i+"_mc"]._y = 402;
_root[boxHolder]["movie_btn_"+i+"_mc"].no = i;
_root[boxHolder]["movie_btn_"+i+"_mc"].onRollOver = function() {
catText.text = catText_arr[this.no];
};
_root[boxHolder]["movie_btn_"+i+"_mc"].onRollOut = function() {
catText.text = "";
};
} else {
clearInterval(runMe);
}
i++;
}
runMe = setInterval(runMovie, 500);
I've been looking at this all morning and would appreciate any help you can give.
Thanks
Mark
I have created a blank movie clip which I am attempting to attach the multiple movies to (changing the x pos each time). What it is doing is creating the first one, then the second one appears next to it in the right place, but then that disappears and the 3rd one appears it its right place and so on through to the end. So I end up with my first one in place and my last one in place.
I am reading from an xml file to get me the count of the buttons and I'm using a setInterval to delay the output of the buttons on the screen (the idea being they appear one after the other, in a row)
Here is my code:
function xmlLoad(loaded) {
if (loaded) {
xmlNode = this.firstChild;
intNum = intNum;
total = xmlNode.childNodes.length;
catText_arr = [];
catID_arr = [];
for (i=0; i<total; i++) {
catText_arr[i] = xmlNode.childNodes[i].attributes.catText;
catID_arr[i] = xmlNode.childNodes[i].attributes.catid;
}
//create the container movie to attach all other to
attachMovie("boxHolder", boxHolder, 0);
i = 0;
runMovie();
} else {
trace("what xml file");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = xmlLoad;
xmlData.load("xml/images.xml");
function runMovie() {
if (i<=catText_arr.length) {
trace("attach movie"+i);
_root[boxHolder].attachMovie("movie_btn", "movie_btn_"+i+"_mc", this.getNextHighestDepth());
_root[boxHolder]["movie_btn_"+i+"_mc"]._x = 640-28*i;
_root[boxHolder]["movie_btn_"+i+"_mc"]._y = 402;
_root[boxHolder]["movie_btn_"+i+"_mc"].no = i;
_root[boxHolder]["movie_btn_"+i+"_mc"].onRollOver = function() {
catText.text = catText_arr[this.no];
};
_root[boxHolder]["movie_btn_"+i+"_mc"].onRollOut = function() {
catText.text = "";
};
} else {
clearInterval(runMe);
}
i++;
}
runMe = setInterval(runMovie, 500);
I've been looking at this all morning and would appreciate any help you can give.
Thanks
Mark