Right now, this code
var gridArray:Array = [[],[],[],[],[],[]];
gridArray[0][0] = new gridProperties;
//gridProperties has gridX and gridY i.e. gridArray[0][0].gridX
function clearGridSquare(gridSquare:gridProperties):void
{
gridSquare = null;
}
function test():void
{
clearGridSquare(gridArray[0][0]);
trace (gridArray[0][0]);
}
produces
[object gridProperties]
instead of null. I understand that since an object is a reference, even though it technically is passed as a value to the function, it acts like it is passed as a reference. In this way I can alter say, the gridX or gridY properties of the original object from within the function (gridSquare.gridX=1), but I cannot actually make the object itself null. I have found that I can make it null if I do this in the function instead:
gridArray[gridSquare.gridY][gridSquare.gridX] = null;
but that seems like I really bad and roundabout way of doing it. Is there a more elegant solution?