Not sure what I’m missing here, but if I create a new AS3 file with the following code:
function createArrays():void {
for(var i:uint=0;i<3;i++){
trace(i);
this["array"+i]=new Array();
this["array"+i].push("item1");
this["array"+i].push("item2");
}
trace(this["array"+0].toString())
}
createArrays();
it traces fine and works…
If I set my document class to tst.as, remove all except the last line and put the following in a tst.as file:
package {
import flash.display.MovieClip;
import flash.events.*;
public class tst extends MovieClip {
public function createArrays():void {
for(var i:uint=0;i<3;i++){
trace(i);
this["array"+i]=new Array();
this["array"+i].push("item1");
this["array"+i].push("item2");
}
trace(this["array"+0].toString())
}
}
}
I get an error saying:
ReferenceError: Error #1056: Cannot create property array0 on tst.
at tst/createArrays()
at tst/frame1()
Am I missing something, or are there functions you can’t build in external as but you can in the IDE?
Thanks!!