Ok, this lack of formal multidimensional arrays in Actionscript is getting to me.
I’m trying to create an array within a class so that it’s flexible enough to dynamically allocate enough space depending on how the instance of the class is specified. Ideally, I want this array’s elements to also be dynamically allocatable.
I’ve used the trick to “force” a multidimensional array in Actionscript by doing something like this before:
var row0:Array = new Array();
var row1:Array = new Array();
var matrix = [row0, row1];
…but this method isn’t practical for dynamically sized arrays. Any other “tricks” you guys might have up your sleeves?
all arrays in Flash are dynamic. You can add or remove any number of elements at runtime without problem. If you want a multidimensional array, you just make an array of arrays.
multidimarray.push(new Array());
presto. You dont have to define them as variables beforehand.