- Home /
Question by
Polygoon · Jul 11, 2012 at 08:47 PM ·
javascriptarrays
2D array error object does not support slicing
Hey everyone, I'm trying to make a grid using a 2d array and I need some help. I keep getting an error at line 39 and 75, The error states that the object does not support slicing. Is there a better way to do this? The lines I'm having problems with look like this:
aGrid[i][j] = new Card;
var card:Object = aGrid[i][j];
here is a good chunk of code that shows the variable and the loops i have for this array.
var aGrid:Array;
for (var i=0; i<rows; i++){
aGrid[i] = new Array();
for(var j=0; j<cols; j++){
aGrid[i][j] = new Card();
}
}
function BuildGrid()
{
GUILayout.BeginVertical();
for(var i=0; i<rows; i++)
{
GUILayout.BeginHorizontal();
for(var j=0; j<cols; j++)
{
var card:Object = aGrid[i][j];
if(GUILayout.Button(Resources.Load(card),
GUILayout.Width(cardW)))
{
Debug.Log(card);
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
Comment