it's because that is the last known value of i and j. When you rollover any mc it will get the present value of 'i' and 'j' not what the value of i and j was when the onRollover event handler was defined for it. What u need to do is create a dynamic property for the movieclip at the time its onRollover handler is being defined e.g
Code:
var str:String;
for(i=0; i<13; i++) {
for(j=0; j<21; j++) {
theScene["mask_"+i+"_"+j].i = i;
theScene["mask_"+i+"_"+j].j = j;
theScene["mask_"+i+"_"+j].onRollOver = function() {
str = "mask_"+this.i+"_"+this.j;
trace(str);
theScene[str].gotoAndPlay(2);
}
}
}
or just
Code:
var str:String;
for(i=0; i<13; i++) {
for(j=0; j<21; j++) {
theScene["mask_"+i+"_"+j].onRollOver = function() {
this.gotoAndPlay(2);
}
}
}
The first one was to illustrate the point