Hi, I'm new to AS loops and need help! I'm using loops to create duplicate movie clips.
There are two MCs on the stage:
targetMC and
otherMC.
makeaLoop should loop through two functions:
myLoop1 and
myLoop2. Each of these functions loop to create duplicate movie clips, either
targetMC 25x vertically or
otherMC 25x horizontally.
While the trace shows that both loops are successful, only the MC in the second function is duplicated. If I switch the order, it always duplicates the MCs in the final function. Why is this?
ActionScript Code:
makeaLoop();
function makeaLoop(){
for (i=1; i<=25; i++) {
myLoop1();
myLoop2();
}
}
function myLoop1(){
for (k=1; k<=25; k++) {
duplicateMovieClip ("targetMC", "dupMC"+k, k);
_root["dupMC"+k]._y = 100 + (k*15);
trace("loop 1");
}
}
function myLoop2(){
for (j=1; j<=25; j++) {
duplicateMovieClip ("otherMC", "dupOtherMC"+j, j);
_root["dupOtherMC"+j]._x = 100 + (j*15);
trace("loop 2");
}
}
Am I missing some key actionscript here? Eventually, I'll embed one loop inside the other to create a grid of clips 25 x 25, is there a better way to do this?
Any help will be appreciated.