The best overload for the method 'UnityScript.Lang.Extensions.get_length(System.Array)' is not compatible with the argument list '(int)'.

I have a code that im trying to create right here that creates a game board using a 3d array in js. I want the board to be 10x10 and have 1 border on both sides (thus 12x12) to keep the pieces on the plane. sadly this is more difficult than it seems in unity js script and i keep getting errors when trying to call my board arrays’ indexes. can someone PLEASE tell me what i am doing wrong?


//Set board width, length and height
var board : int[]  = [12, 12, 24]; 

//--------------------------------

function GenBoard(){
	
	var cube : GameObject;
	var material : Material;

    for(var x : int = 0; x < board.length[0]; x++){
    
	    for(var z : int = 0; z < board.length[1]; x++){
	    
	        for(var y : int = 0; y < board.length[2];y++){
	        
	            if(x < 11 && x > 0){
	            
	            	if(z < 11 && x > 0){
	            
		                if(y > 0 && y < board.length[1]-2){
		                
		                    //Board
		                    board[x, y, z] = 0;
		                    cube = GameObject.CreatePrimitive( PrimitiveType.Cube );
		                    cube.transform.position = new Vector3(x, y, z);
		                    material = new Material(Shader.Find("Diffuse"));
		                    material.color = Color.grey;
		                    cube.renderer.material = material;
		                    cube.transform.parent = transform;
		                    
		                }
		                else if(y < board.length[1]-2){
		                
		                    board[x, y, z] = 1;
		                    cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
		                    cube.transform.position = new Vector3(x, y, z);
		                    material = new Material(Shader.Find("Diffuse"));
		                    material.color = Color.black;
		                    cube.renderer.material = material;
		                    cube.transform.parent = transform;
		                    cube.collider.isTrigger = true;
	                     
	                }
	                
	            }
		
			}
	            else if(y < board.length[1] -2){
	            
	                //Left and right edge
	                board[x, y, z] = 1;
	                cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
	                cube.transform.position = new Vector3(x, y, z);
	                material = new Material(Shader.Find("Diffuse"));
	                material.color = Color.black;
	                cube.renderer.material = material;
	                cube.transform.parent = transform;
	                
	            }
	            
	        }
	        
	    }
	    
	}
	    
}

http://docs.unity3d.com/ScriptReference/Array-length.html

Length returns the size of the array. You are trying to use it against each element.

i figured it out guys thank you. It seems that the syntax for using a MultiDim Array in unity jsScript has a trick to it using nested Arrays with no type declaration. Therefor i can create an int32 using as many dimensions as i want. The syntax is as follows:

`// equivalent of 3d Array multiDim

var multiDim = [ [[1, 2, 3], [“x”, “y”, “z”]], [[“Colors”]], [[“red”, “blue”, “pink”]]];

so instead of var board : int = [12, 12, 24];

i needed to do:

var board = [

[[0,0,0], [0,1,0], [0,2,0], [0,3,0], [0,4,0], [0,5,0], [0,6,0], [0,7,0], [0,8,0], [0,9,0], [0,10,0], [0,11,0]],

[[1,0,0], [1,1,0], [1,2,0], [1,3,0], [1,4,0], [1,5,0], [1,6,0], [1,7,0], [1,8,0], [1,9,0], [1,10,0], [1,11,0]],

[[0,0,1], [0,0,2], [0,0,3], [0,0,4], [0,0,5], [0,0,6], [0,0,7], [0,0,8], [0,0,9], [0,0,10], [0,0,11], [0,0,12],
[0,0,13], [0,0,14], [0,0,15], [0,0,16], [0,0,17], [0,0,18], [0,0,19], [0,0,20], [0,0,21], [0,0,22], [0,0,23]]
];	

`