Yeah Thoriel is right. Use a for loop instead
[AS]
for (i=1;i<=20;i++) {
duplicateMovieClip(_root.box, “box”+i, i);
mc = _root[“box”+i]
mc.onRelease = function (){…} /* mc targets all duplicated movieclips /
}
_root[“box”+3].onRelease = function (){…}/ _root[“box”+3] targets the third duplicated movieclip */
[/AS]
The following code is an example. You’ll see
[AS]
for (i=1; i<=20; i++) {
_root.box._visible = false;
duplicateMovieClip(_root.box, “box”+i, i);
mc = _root[“box”+i];
mc._x = i*40
}
_root[“box”+3]._visible = false;
[/AS]
‘boxnr’ and ‘alphaspeed’ are variables that the function uses. When you call the function:
[AS]
fadeOut(3, alphaspeed);
[/AS]
you need to assign values to those vars for the function to use.
In the meantime, i must tell you that i also tried this:
[AS]
function fadeFunction() {
fadeOut(boxnum, alphaspeed)
}
Interval = setInterval(fadeFunction, 1000);
[/AS]
[AS]
function fadeOut(startboxnr) {
clearInterval(Interval);
_root.onEnterFrame = function() {
_root[“box”+startboxnr]._alpha -= 10;
if (_root[“box”+startboxnr]._alpha<=0) {
startboxnr++;
Interval = setInterval(fadeOut, 500, startboxnr);
delete this.onEnterFrame;
}
};
}
for (i=1; i<20; i++) {
_root.box._visible = false;
duplicateMovieClip(_root.box, “box”+i, i);
_root[“box”+i]._x = 17*i;
}
//Set the initial interval (= the time before it starts fading)
Interval = setInterval(fadeOut, 1000, 0);
[/AS]
This will make the next box start to fade after the one that is currently fading has finished fading. Here, setInterval indicates the time between one has finished fading and another one starts. If you want them to fade right after eachother, set 500 to 1.
If you want to start them fading immediately, change the 1000 from the inital interval to 1.
At first, you won’t notice they are fading but they are. That’s because it decreases with 10. 100-10 = 90, so still very good visible. Around about 60-70 you notice it fading.
And, to make them fade more quickly, increase 10 in [AS][“box”+startboxnr]._alpha -= 10;[/AS]
ok thanks, everything is great, but to be more specific to my problem (which i tried to work on more from your code), i sort of want the next box to start fading when the first box’s alpha is on 50. I have got this:
As you can see, that decreases 10 from each box before it goes back to the first one. I’ve tried many times but this is the closest i can get. So i was wondering how i could change this code so it decreases 10 from the first box until the alpha hits 0. Then, while it is decreasing alpha from the first box, it begins the second. Thanks. You don’t havta help me if you don’t want
EDIT: oh yea btw, if you have an idea on this but dont’ have the time to code it that would help me too thanks
**ok thanks, everything is great, but to be more specific to my problem (which i tried to work on more from your code), i sort of want the next box to start fading when the first box’s alpha is on 50. I have got this:
**