Multidirectional arrays on javascript

Ok, Unity 3.4 has support for multidirectional arrays on JS. But Im having troubles initializing them. Here’s my example:

var myArray : Array;

function Start() {
myArray = new Array();
myArray[0][0] = 1;
myArray[0][1] = 2;
myArray[2][3] = 3;
myArray[2][4] = 4;
myArray[3][0] = 5;
}

But when I try to use it it seems to be empty. What Im doing wrong?

Console Error: “ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.”

Thanks!

You mean “multidimensional”, not “multidirectional”. Array is obsolete and pretty much shouldn’t ever be used. Use built-in arrays or Lists instead. A multidimensional array is declared like this:

var myArray : int[,];

function Start () {
	myArray = new int[4,4];
	myArray[0,0] = 1;
	myArray[0,1] = 2;
}

does that work?

var myArray : Array;

function Start() { 
    myArray = new Array(); 
    myArray[0] = new Array();
    myArray[0][0] = 1;     
    myArray[0][1] = 2;
    myArray[2] = new Array();
    myArray[2][3] = 3; 
    myArray[2][4] = 4; 
    myArray[3] = new Array();    
    myArray[3][0] = 5; 
}