Type Object Slicing error

I am getting the following error in my code and I can’t seem to understand why? Can anyone help me with this error.

This is my current code.

var rows : int = 4;
var cols : int = 4;
var totalCards : int = cols * rows;
var matchesNeedToWin : int = totalCards * 0.5; 
var matchesMade : int = 0;

var cardW : int = 100;
var cardH : int = 100;

var aCards : Array; 
var aGrid : Array;

// This Array will store the two cards that the player flipped
var aCardsFlipped : ArrayList; 

// To prevent player from clicking buttons when we don't want him to
var playerCanClick : boolean; 

var playerHasWon : boolean = false;		

	
class Card extends System.Object {
var isFaceUp : boolean = false;
var isMatched : boolean = false;
var img : String;
	
	function Card () {
		img = "robot";
	}
}

function Start () {
	
	var i : int = 0;
	var j : int = 0;
	
	playerCanClick = true;
	aCards = new Array ();
	aGrid = new Array ();
	aCardsFlipped = new ArrayList ();
	
	for ( i = 0; i < rows; i++) {
		aGrid  *= new Array ();*
  •   		for (j = 0; j < cols; cols++ ) {*
    

_ aGrid [j] = new Card (); // Error over here_
* }*
* }*
* }*

* function Update () {*
* Debug.Log(“Game Screen has loaded”);*
* }*
I am getting the error in the following function start () {}
aGrid [j] = new Card (); The error states as follows:
> Error BCE0048: Type ‘Object’ does not support slicing. (BCE0048) (Assembly-UnityScript)
Any suggestions are welcome!
Thank you!
Vish

aGrid is an array, not an array of array. Which means aGrid is an Object.
Try var aGrid : Card[,], or take a look at [that][1].
[1]: unifycommunity.com

Hi I had the same problem and my solution for that was: It works for me =)

function Start(){
    playerCanClick = true;
    aCards = new Array();
    aGrid = new Array();
    aCardsFlipped = new ArrayList();
    for(var i=0; i<rows; i++){
        var acrds:Array=new Array();
        for(var j=0; j<cols; j++){
            acrds[j]= new Card();
        }
        aGrid*=acrds;*

}
}

Found this solution online as another user had similar issue and he recommended that the following line should be commented //#pragma strict

I solved this using the following code:

function Start ()
{
playerCanClick = true;
// initialize the arrays as empty list:
aCards = new Array();
aGrid = new Array();
aCardsFlipped = new Array();

for(i=0;i<rows;i++)
{
	for(j=0;j<cols;j++)
	{
		var card:Card = new Card();
		aGrid.Add(card);
	}
}

}

Then you can call aGrid array like this:

for(i=0;i<rows;i++)
{
	GUILayout.BeginHorizontal();
	for(j=0;j<cols;j++)
	{
		var card:Card = aGrid[i+cols*j];
		if(GUILayout.Button(Resources.Load(card.img),GUILayout.Width(cardW)))
		{
			Debug.Log(card.img);
		}
	}
	GUILayout.EndHorizontal();
}