Here's the code:
on (press) {
for (var i = 0; i<=4; i++) {
k = random(3);
pp = new Array();
for (var j = 0; j<=k; j++) {
pp[j] = dofunction();
}
this["text"+i] = pp.join(" / ");
trace("returned text "+i+" = "+this["text"+i]);
_global.dofunction = function() {
return "some text";
};
}
}
Here's the output:
returned text 0 = undefined / undefined / undefined
returned text 1 = some text / some text / some text
returned text 2 = some text / some text
returned text 3 = some text / some text / some text
returned text 4 = some text / some text
Why is the first return an Undefined? Sometimes (in different versions of the script) it returns NaN for the first run through but then is fine. I have tried to call "i" as a number intially : i = Number(i); and I have tried to incriment it at the start of the script : i++; but nothing seems to help.
Thanks in advance crew!
Aaron