I'm trying to create a 2D array for coordinates like [[x_1,y_1,z_1], [x_2,y_2,z_2], [...],...].
Here is my code for initialization and initial declaration:
var ALLcoordinates:number[][];
for (var i=0; i< dims; i++) {
ALLcoordinates[i]=[];
for (var j=0; j<chainSize; j++){
ALLcoordinates[i][j]=0;
}
}
After that, I assign new values for each row in this loop :
for (var i = 0; i < chainSize; i++) {
var alea1 = Math.floor(Math.random()*(3-0+1))+0;
var alea2 = Math.floor(Math.random()*(3-0+1))+0;
var alea3 = Math.floor(Math.random()*(3-0+1))+0;
var coordinates:number[];
coordinates = [alea1,alea2,alea3];
ALLcoordinates[i]=coordinates;
}
But when I compile it, I get this error Uncaught TypeError: Cannot set property '0' of undefined for this line ALLcoordinates[i] = [];
I would appreciate any help, thanks