Skip to main content
to clarify
Source Link

ThisLike Jonathan Hobbs said, I've made a few changes.
This is what I modified those code

var cardW:int = 100; //card width = 100
var cardH:int = 100;
var aCards:Array; //every cards will be stored in this array
//var aGrid:Array; //this array will keep track of the shuffled, dealt cardsArray
var aGrid:Card[,];
var aCardsFlipped:ArrayList; // This array will store the two cards that player flips over
var<-- playerCanClick:boolean;change //Wehow willyou usedeclare this flag to prevent the player from clicking buttons when we don't want himvariable to
var playerHasWon:boolean = false; // Store wehter or not the player has won


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

And change this in the Start function

function Start () {
    playerCanClick = true; 
    //initialize the array as empty lists
    aCards = new Array();
    aGrid = new Card[rows,cols]; //<-- I instantiate beforeit useas rows*cols array
    aCardsFlipped = new ArrayList();
    for (var i=0;i<rows;i++)
    {
        for (var j=0;j<cols;j++)
        {
            aGrid[i,j] = new Card(); //Assign<-- Then assign the value like this
        }
    }
}

Hope this help

This is what I modified those code

var cardW:int = 100; //card width = 100
var cardH:int = 100;
var aCards:Array; //every cards will be stored in this array
//var aGrid:Array; //this array will keep track of the shuffled, dealt cards
var aGrid:Card[,];
var aCardsFlipped:ArrayList; // This array will store the two cards that player flips over
var playerCanClick:boolean; //We will use this flag to prevent the player from clicking buttons when we don't want him to
var playerHasWon:boolean = false; // Store wehter or not the player has won


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

function Start () {
    playerCanClick = true; 
    //initialize the array as empty lists
    aCards = new Array();
    aGrid = new Card[rows,cols]; //instantiate before use
    aCardsFlipped = new ArrayList();
    for (var i=0;i<rows;i++)
    {
        for (var j=0;j<cols;j++)
        {
            aGrid[i,j] = new Card(); //Assign the value like this
        }
    }
}

Hope this help

Like Jonathan Hobbs said, I've made a few changes.
This is what I modified those code

var aCards:Array
var aGrid:Card[,]; //<-- change how you declare this variable to multidimensional arrays
var aCardsFlipped:ArrayList;

And change this in the Start function

function Start () {
    playerCanClick = true; 
    aCards = new Array();
    aGrid = new Card[rows,cols]; //<-- I instantiate it as rows*cols array
    aCardsFlipped = new ArrayList();
    for (var i=0;i<rows;i++)
    {
        for (var j=0;j<cols;j++)
        {
            aGrid[i,j] = new Card(); //<-- Then assign the value like this
        }
    }
}

Hope this help

Source Link

This is what I modified those code

var cardW:int = 100; //card width = 100
var cardH:int = 100;
var aCards:Array; //every cards will be stored in this array
//var aGrid:Array; //this array will keep track of the shuffled, dealt cards
var aGrid:Card[,];
var aCardsFlipped:ArrayList; // This array will store the two cards that player flips over
var playerCanClick:boolean; //We will use this flag to prevent the player from clicking buttons when we don't want him to
var playerHasWon:boolean = false; // Store wehter or not the player has won


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

function Start () {
    playerCanClick = true; 
    //initialize the array as empty lists
    aCards = new Array();
    aGrid = new Card[rows,cols]; //instantiate before use
    aCardsFlipped = new ArrayList();
    for (var i=0;i<rows;i++)
    {
        for (var j=0;j<cols;j++)
        {
            aGrid[i,j] = new Card(); //Assign the value like this
        }
    }
}

Hope this help