welcome to the army of AS3 developers.
Here's few tips for you:
- Arrays can be defined as
var array:Array = [];
and here's a 2d Array -var a:Array = [[]];
. Arrays are dynamic object, you don't need to specify the depth of the array. So when adding tile to the array just add them viaarray[x][y] = tile
- Having said that, don't use arrays :) You strictly typed collectors called Vectors. You need to define Vectors: 1d
var myVector:Vector.< Tile > = new Vector.< Tile >();
and 2d versionvar myVector:Vector< Vector.< Tile > >;
and so on.
Vectors are faster than Arrays.
More tips:
- Saving black and write tiles in Library and constructing the grid on run-time might be better for you.
- Accessing object on screen by their instance names is a bad idea - a lot of work and poor maintainability. Plus you won't be able to access them before the scene is finished building and you'll access them as Dynamic objects, you'll need to cast them to your needed class to work with them normally. That also leads to silent bugs since you won't get warning on compile time if you try to access something illegal.