Taking Piece Chess Problem

Hello,

I have been making a chess flash game for the past x amount of time. However I have encountered a problem when I take a piece. I cannot work out how to actually take the piece.

Here is my code
This is the function that handles the move


function handleMove(type:String, piece:String, xpos:int, ypos:int)
{
 switch (type)
 {
  case "up":
   heldPiece = chessPieces[ypos][xpos];
   chessPieces[ypos][xpos] = "0"
  break;
  case "down":
   takePiece(heldPiece, xpos, ypos, piece);
   clearBoard(piece);
  break;
 }
 trace(chessPieces);
 trace("(" + xpos + " , " + ypos + ") - " + piece + " - " + type)
}

Within the case “down” calls the takePiece function and the clearBoard function they are as follows:


function takePiece(heldPiece:int, xpos:int, ypos:int, piece:String)
{
 if(chessPieces[ypos][xpos] == "0")
 {
  chessPieces[ypos][xpos] = heldPiece;
 } else {
  takenPiece = chessPieces[ypos][xpos];
  trace(takenPiece);
  chessPieces[ypos][xpos] = heldPiece;
 }
}


function clearBoard(piece:String)
{
 removeChild(BpawnChess);
}

This is giving me an error

Implicit coercion of a value of type Class to an unrelated type flash.display: DisplayObject.

I had planned to take the piece and basically redraw the chessPieces array in a new position, since there are only 32 pieces it shouldn’t cause any lag.

I honestly don’t know what to do. If you need anything else for clarification let me know.

Thanks

WarChimp