The following script, which has been adapted from a grid generation script, does just what it says on the tin – traces “p” out 352 times;
[AS]for (var i = 1; i<=16; ++i) {
for (var p = 1; p<=22; ++p) {
var x = (p-1)*spacing;
var y = (i-1)*spacing;
var name = “cell”+p+"_"+i;
hold_array.push(name);
this.holdit_mc.nhold_mc.attachMovie(“little”, name, ++depth);
this.holdit_mc.nhold_mc[name]._x = x;
this.holdit_mc.nhold_mc[name]._y = y;
}
}
for (p=0; p<=352; p++) {
trace§;
}[/AS]
But… if I change the loop to the following;
[AS]for (p=0; p<=hold_array.length; p++) {
trace§;
}[/AS]
all hell breaks loose & Flash advises me to dump the script?
Is it that the “loop” is being called BEFORE hold_array has had a chance to be populated?
Many thanks for any help.