I’m trying to get a multidimensional array working. I have:
// Global variable grid of Cards (Cards is my own class)
var aGrid : Cards[,];
function Start(){
// Init aGrid
for( var i = 0; i < 4; ++i ){
for( var j = 0; i < 4; ++i ){
aGrid[ i, j ] = new Card();
}
}
}
function accessGrid(){
// Try to access initialized aGrid
// This bombs, saying aGrid is a null value
var card : Card = aGrid[ intX, intY ];
}
When I run the app, the accessing of aGrid fails saying aGrid is null, even though the intX and intY indexing variables are valid (i.e., are values between 0<4).
Didn’t I initialize aGrid correctly in the Start() function? Do I need some type of aGrid = new Card[4,4]; statement?