Frame 1
if (false) {
}
function buildTheBoard() {
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 8) {
theD++;
_root.attachMovie("CHESScarreBoard", (("piece_" + i) + "_") + j, theD);
_root[(("piece_" + i) + "_") + j]._x = (j * theW) + 12;
_root[(("piece_" + i) + "_") + j]._y = (i * theH) + 12;
if (j % 2) {
if (!(i % 2)) {
(_root[(("piece_" + i) + "_") + j].bois.gotoAndStop(2));// not popped
} else {
(_root[(("piece_" + i) + "_") + j].bois.gotoAndStop(1));// not popped
}
} else {
if (!(i % 2)) {
(_root[(("piece_" + i) + "_") + j].bois.gotoAndStop(1));// not popped
} else {
(_root[(("piece_" + i) + "_") + j].bois.gotoAndStop(2));// not popped
}
}
}
}
}
function buildCapturePieces() {
_root.capturedWhite = 0;
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 2) {
_root.capturedWhite++;
theD++;
_root.attachMovie("CHESSpiece", "capturedpieceb_" + _root.capturedWhite, theD);
_root["capturedpieceb_" + _root.capturedWhite]._xscale = 75;
_root["capturedpieceb_" + _root.capturedWhite]._yscale = 75;
_root["capturedpieceb_" + _root.capturedWhite]._x = (j * (theW / 2)) + 340;
_root["capturedpieceb_" + _root.capturedWhite]._y = (i * (theH / 2)) + 12;
}
}
_root.capturedBlack = 0;
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 2) {
_root.capturedBlack++;
theD++;
_root.attachMovie("CHESSpiece", "capturedpiecew_" + _root.capturedBlack, theD);
_root["capturedpiecew_" + _root.capturedBlack]._xscale = 75;
_root["capturedpiecew_" + _root.capturedBlack]._yscale = 75;
_root["capturedpiecew_" + _root.capturedBlack]._x = (j * (theW / 2)) + 340;
_root["capturedpiecew_" + _root.capturedBlack]._y = ((i * (theH / 2)) + 12) + 96;
}
}
_root.capturedWhite = 0;
_root.capturedBlack = 0;
}
_root.attachMovie("titleScreen", "titleScreen", 10000);
var theD = 0;
var theW = 24;
var theH = 24;
buildTheBoard();
buildCapturePieces();
Frame 4
if (false) {
}
function drawHistoryBar(x, y, thewidth, theheight) {
_root.createTextField("myTextField", 1000, x, y, thewidth, theheight);
myTextField.wordWrap = true;
myTextField.html = true;
initialization = {_targetInstanceName:"myTextField", horizontal:false};
_root.attachMovie("FScrollBarSymbol", "myScrollbar", 2000, initialization);
myScrollBar._x = myTextField._width + x;
myScrollBar.setSize(myTextField._height);
}
function writeHistory(thetext) {
_root.myTextField.htmlText = _root.myTextField.htmlText + ((("<FONT FACE='Verdana,Arial' SIZE='10' COLOR='#FFFFFF'>" + thetext) + "</FONT>") + newline);
_root.myTextField.scroll = _root.myTextField.maxscroll;
}
function MovementRules() {
this.up = 0;
this.down = 0;
this.left = 0;
this.right = 0;
this.up_left = 0;
this.up_right = 0;
this.down_left = 0;
this.down_right = 0;
this.isKnight = false;
this.isPawn = false;
}
function Move(firstPosX, firstPosY, lastPosX, lastPosY) {
this.fPX = firstPosX;
this.fPY = firstPosY;
this.lPX = lastPosX;
this.lPY = lastPosY;
}
function identifyPiece(piece) {
switch (piece) {
case PAWN_W :
return("P");
case PAWN_B :
return("P");
case KNIGHT_W :
return("Kn");
case KNIGHT_B :
return("Kn");
case ROOK_W :
return("R");
case ROOK_B :
return("R");
case BISSHOP_W :
return("B");
case BISSHOP_B :
return("B");
case QUEEN_W :
return("Q");
case QUEEN_B :
return("Q");
case KING_W :
return("K");
case KING_B :
return("K");
}
}
function rulesFor(piece) {
switch (piece) {
case PAWN_W :
return(pawnRules);
case PAWN_B :
return(pawnRules);
case KNIGHT_W :
return(knightRules);
case KNIGHT_B :
return(knightRules);
case ROOK_W :
return(rookRules);
case ROOK_B :
return(rookRules);
case BISSHOP_W :
return(bisshopRules);
case BISSHOP_B :
return(bisshopRules);
case QUEEN_W :
return(queenRules);
case QUEEN_B :
return(queenRules);
case KING_W :
return(kingRules);
case KING_B :
return(kingRules);
}
}
function initChessBoard() {
movesHistory = 1;
chessBoard = [[ROOK_B, KNIGHT_B, BISSHOP_B, QUEEN_B, KING_B, BISSHOP_B, KNIGHT_B, ROOK_B], [PAWN_B, PAWN_B, PAWN_B, PAWN_B, PAWN_B, PAWN_B, PAWN_B, PAWN_B], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [PAWN_W, PAWN_W, PAWN_W, PAWN_W, PAWN_W, PAWN_W, PAWN_W, PAWN_W], [ROOK_W, KNIGHT_W, BISSHOP_W, QUEEN_W, KING_W, BISSHOP_W, KNIGHT_W, ROOK_W]];
chessBoardlm = [[VOID, VOID, VOID, BISSHOP_W, KING_B, BISSHOP_W, VOID, VOID], [VOID, VOID, ROOK_W, ROOK_W, VOID, ROOK_W, ROOK_W, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, PAWN_B, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [PAWN_B, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, BISSHOP_W, VOID, KING_W, VOID, VOID, VOID]];
chessBoardm = [[VOID, VOID, VOID, VOID, KING_B, VOID, VOID, VOID], [VOID, VOID, ROOK_W, VOID, VOID, ROOK_B, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [PAWN_B, VOID, VOID, VOID, VOID, VOID, VOID, VOID], [VOID, VOID, BISSHOP_W, VOID, KING_W, VOID, VOID, VOID]];
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 8) {
_root[(("piece_" + i) + "_") + j].showPiece(chessBoard[i][j]);
_root[(("piece_" + i) + "_") + j].row = i;
_root[(("piece_" + i) + "_") + j].col = j;
}
}
}
function calculateMoves(row, col, side) {
if (chessBoard[row][col] == VOID) {
return(null);
}
var poMo = new Array();
rules = rulesFor(chessBoard[row][col]);
var poTa;
if (rules.isKnight) {
var x = (row - 1);
var y = (col + 2);
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row - 1;
y = col - 2;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row + 1;
y = col + 2;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row + 1;
y = col - 2;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row - 2;
y = col + 1;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row - 2;
y = col - 1;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row + 2;
y = col - 1;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
x = row + 2;
y = col + 1;
if ((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) {
if ((chessBoard[x][y] == VOID) || (side != (chessBoard[x][y] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
return(poMo);
}
if (rules.isPawn) {
if (side == 1) {
var possibleEmpassant = false;
var i = (row - 1);
if (chessBoard[i][col] == VOID) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | col;
possibleEmpassant = true;
}
if ((row == 6) && (possibleEmpassant)) {
i--;
if (chessBoard[i][col] == VOID) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | col;
}
}
var x = (row - 1);
var y = (col - 1);
if (((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) && ((chessBoard[x][y] != VOID) && (side != (chessBoard[x][y] & 1)))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
var x = (row - 1);
var y = (col + 1);
if (((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) && ((chessBoard[x][y] != VOID) && (side != (chessBoard[x][y] & 1)))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
} else {
var possibleEmpassant = false;
var i = (row + 1);
if (chessBoard[i][col] == VOID) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | col;
possibleEmpassant = true;
}
if ((row == 1) && (possibleEmpassant)) {
i++;
if (chessBoard[i][col] == VOID) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | col;
}
}
x = row + 1;
y = col - 1;
if (((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) && ((chessBoard[x][y] != VOID) && (side != (chessBoard[x][y] & 1)))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
x = row + 1;
y = col + 1;
if (((((x >= 0) && (x < 8)) && (y >= 0)) && (y < 8)) && ((chessBoard[x][y] != VOID) && (side != (chessBoard[x][y] & 1)))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (x << 3)) | y;
}
}
return(poMo);
}
var delta = rules.up;
var i = (row - 1);
while (true) {
if (!((0 < delta) && (i >= 0))) {
break;
}
if ((chessBoard[i][col] == VOID) || (side != (chessBoard[i][col] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | col;
} else {
break;
}
if (chessBoard[i][col] != VOID) {
break;
}
i--;
delta--;
}
var delta = rules.down;
var i = (row + 1);
while (true) {
if (!((0 < delta) && (i < 8))) {
break;
}
if ((chessBoard[i][col] == VOID) || (side != (chessBoard[i][col] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | col;
} else {
break;
}
if (chessBoard[i][col] != VOID) {
break;
}
i++;
delta--;
}
var delta = rules.left;
var j = (col - 1);
while (true) {
if (!((0 < delta) && (j >= 0))) {
break;
}
if ((chessBoard[row][j] == VOID) || (side != (chessBoard[row][j] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (row << 3)) | j;
} else {
break;
}
if (chessBoard[row][j] != VOID) {
break;
}
j--;
delta--;
}
var delta = rules.right;
var j = (col + 1);
while (true) {
if (!((0 < delta) && (j < 8))) {
break;
}
if ((chessBoard[row][j] == VOID) || (side != (chessBoard[row][j] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (row << 3)) | j;
} else {
break;
}
if (chessBoard[row][j] != VOID) {
break;
}
j++;
delta--;
}
var delta = rules.up_left;
var i = (row - 1);
var j = (col - 1);
while (true) {
if (!(((0 < delta) && (j >= 0)) && (i >= 0))) {
break;
}
if ((chessBoard[i][j] == VOID) || (side != (chessBoard[i][j] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | j;
} else {
break;
}
if (chessBoard[i][j] != VOID) {
break;
}
i--;
j--;
delta--;
}
var delta = rules.up_right;
var i = (row - 1);
var j = (col + 1);
while (true) {
if (!(((0 < delta) && (j < 8)) && (i >= 0))) {
break;
}
if ((chessBoard[i][j] == VOID) || (side != (chessBoard[i][j] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | j;
} else {
break;
}
if (chessBoard[i][j] != VOID) {
break;
}
i--;
j++;
delta--;
}
var delta = rules.down_left;
var i = (row + 1);
var j = (col - 1);
while (true) {
if (!(((0 < delta) && (j >= 0)) && (i < 8))) {
break;
}
if ((chessBoard[i][j] == VOID) || (side != (chessBoard[i][j] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | j;
} else {
break;
}
if (chessBoard[i][j] != VOID) {
break;
}
i++;
j--;
delta--;
}
var delta = rules.down_right;
var i = (row + 1);
var j = (col + 1);
for(;;){
if (!(((0 < delta) && (j < 8)) && (i < 8))) {
// unexpected jump
}
if ((chessBoard[i][j] == VOID) || (side != (chessBoard[i][j] & 1))) {
poMo[poMo.length] = (((row << 9) | (col << 6)) | (i << 3)) | j;
} else {
return(poMo);
}
if (chessBoard[i][j] != VOID) {
return(poMo);
}
i++;
j++;
delta--;
};
return(poMo);
}
function checkChessState(side) {
var row;
var col;
var i = 0;
if (TWOPLAYERS_MODE == false) {
while (i < 8) {
var j = 0;
while (j < 8) {
if (((chessBoard[i][j] & 1) == getOpponent(side)) && (chessBoard[i][j] != VOID)) {
compMoves = calculateMoves(i, j, getOpponent(side));
if (SIDE_PLAYER == 1) {
ourKing = KING_W;
opponentKing = KING_B;
} else {
ourKing = KING_B;
opponentKing = KING_W;
}
var k = 0;
while (k < compMoves.length) {
row = (compMoves[k] >> 3) & 7;
col = compMoves[k] & 7;
if (((chessBoard[row][col] == ourKing) && (side == SIDE_PLAYER)) || ((chessBoard[row][col] == opponentKing) && (side == SIDE_COMPUTER))) {
kingInChess(row, col, side);
return(false);
}
k++;
}
}
j++;
}
i++;
}
if (compMoves.length == 0) {
_root.messages.gotoAndStop("Pat");
_root.debug = "pat comp";
return(true);
}
}
if (side == SIDE_PLAYER) {
var totalMoves = 0;
var i = 0;
while (i < 8) {
var j = 0;
while (j < 8) {
if (((chessBoard[i][j] & 1) == SIDE_PLAYER) && (chessBoard[i][j] != VOID)) {
totalMoves = totalMoves + select(i, j, true);
}
j++;
}
i++;
}
if (totalMoves == 0) {
invalidateAll();
_root.debug = "pat player";
_root.messages.gotoAndStop("Pat");
}
}
return(true);
}
function computerLoose() {
invalidateAll();
_root.messages.gotoAndStop(2);
stop();
}
function deselect(piece) {
resetAllSelection();
pieceSelected = null;
possiblePositions = null;
}
function displayMove(move, side) {
var fPX = ((move >> 9) & 7);
var fPY = ((move >> 6) & 7);
var lPX = ((move >> 3) & 7);
var lPY = (move & 7);
var thetext = ((movesHistory++) + ". ");
if (side == 1) {
thetext = thetext + "White: ";
} else {
thetext = thetext + "Black: ";
}
thetext = thetext + identifyPiece(chessBoard[lPX][lPY]);
thetext = thetext + letters[fPY];
thetext = thetext + numbers[fPX];
thetext = thetext + "-";
thetext = thetext + letters[lPY];
thetext = thetext + numbers[lPX];
_root.writeHistory(thetext);
}
function do_move(move, side) {
var pieceCaptured = VOID;
var fPX = ((move >> 9) & 7);
var fPY = ((move >> 6) & 7);
var lPX = ((move >> 3) & 7);
var lPY = (move & 7);
if (side == SIDE_COMPUTER) {
if (chessBoard[lPX][lPY] != VOID) {
pieceCaptured = chessBoard[lPX][lPY];
playerScore = playerScore - (chessBoard[lPX][lPY] >> 1);
computerScore = computerScore + (chessBoard[lPX][lPY] >> 1);
}
chessBoard[lPX][lPY] = chessBoard[fPX][fPY];
chessBoard[fPX][fPY] = VOID;
return(pieceCaptured);
}
if (chessBoard[lPX][lPY] != VOID) {
pieceCaptured = chessBoard[lPX][lPY];
playerScore = playerScore + (chessBoard[lPX][lPY] >> 1);
computerScore = computerScore - (chessBoard[lPX][lPY] >> 1);
}
chessBoard[lPX][lPY] = chessBoard[fPX][fPY];
chessBoard[fPX][fPY] = VOID;
return(pieceCaptured);
}
function invalidateAll() {
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 8) {
_root[(("piece_" + i) + "_") + j].marker.gotoAndStop("disabled");
}
}
}
function movePlayer() {
resetAllSelection();
if (SIDE_PLAYER != 1) {
(messages.gotoAndStop(10));// not popped
} else {
(messages.gotoAndStop(1));// not popped
}
checkChessState(SIDE_PLAYER);
}
function moveRealPlayer(move, side) {
var fPX = ((move >> 9) & 7);
var fPY = ((move >> 6) & 7);
var lPX = ((move >> 3) & 7);
var lPY = (move & 7);
if (pieceSelected == null) {
return(undefined);
}
if (side == 1) {
ourKing = KING_W;
ourRook = ROOK_W;
ourPawn = PAWN_W;
ourQUEEN = QUEEN_W;
ourPromotion = 0;
} else {
ourKing = KING_B;
ourRook = ROOK_B;
ourPawn = PAWN_B;
ourQUEEN = QUEEN_B;
ourPromotion = 7;
}
if ((chessBoard[fPX][fPY] == ourKing) && (chessBoard[lPX][lPY] == ourRook)) {
_root.writeHistory("<FONT COLOR='#FF0000'>Rocade</FONT>");
if (side == SIDE_COMPUTER) {
SIDE_COMPUTER_possibleRocade = false;
} else {
SIDE_PLAYER_possibleRocade = false;
}
_root.debug2 = "562";
chessBoard[fPX][fPY] = VOID;
chessBoard[lPX][lPY] = VOID;
if (fPY < lPY) {
chessBoard[fPX][fPY + 2] = ourKing;
chessBoard[fPX][fPY + 1] = ourRook;
_root[(("piece_" + fPX) + "_") + (fPY + 1)].showPiece(chessBoard[fPX][fPY + 1]);
_root[(("piece_" + fPX) + "_") + (fPY + 2)].showPiece(chessBoard[fPX][fPY + 2]);
} else {
chessBoard[fPX][fPY - 2] = ourKing;
chessBoard[fPX][fPY - 1] = ourRook;
_root[(("piece_" + fPX) + "_") + (fPY - 1)].showPiece(chessBoard[fPX][fPY - 1]);
_root[(("piece_" + fPX) + "_") + (fPY - 2)].showPiece(chessBoard[fPX][fPY - 2]);
}
_root[(("piece_" + lPX) + "_") + lPY].showPiece(chessBoard[lPX][lPY]);
_root[(("piece_" + fPX) + "_") + fPY].showPiece(chessBoard[fPX][fPY]);
} else {
if ((chessBoard[fPX][fPY] == ourKing) || (chessBoard[fPX][fPY] == ourRook)) {
if (side == SIDE_COMPUTER) {
SIDE_COMPUTER_possibleRocade = false;
} else {
SIDE_PLAYER_possibleRocade = false;
}
_root.debug2 = "580";
}
var tgt = chessBoard[lPX][lPY];
if (((tgt & 1) == SIDE_COMPUTER) && (tgt != VOID)) {
_root.writeHistory("<FONT COLOR='#FF0000'>Capture!</FONT>");
_root.capturedBlack++;
_root["capturedpiecew_" + _root.capturedBlack].showPiece(tgt);
}
chessBoard[lPX][lPY] = chessBoard[fPX][fPY];
chessBoard[fPX][fPY] = VOID;
_root[(("piece_" + lPX) + "_") + lPY].showPiece(chessBoard[lPX][lPY]);
_root[(("piece_" + fPX) + "_") + fPY].showPiece(VOID);
}
invalidateAll();
if ((lPX == ourPromotion) && (chessBoard[lPX][lPY] == ourPawn)) {
chessBoard[lPX][lPY] = ourQueen;
_root[(("piece_" + lPX) + "_") + lPY].showPiece(ourQueen);
}
displayMove(move, SIDE_PLAYER);
if (TWOPLAYERS_MODE == false) {
gotoAndPlay (7);
} else {
if (SIDE_PLAYER == 1) {
SIDE_PLAYER = 0;
SIDE_COMPUTER = 1;
} else {
SIDE_PLAYER = 1;
SIDE_COMPUTER = 0;
}
movePlayer();
}
}
function moveComputer() {
invalidateAll();
playerScore = 1078;
gotoAndPlay (7);
}
function moveRealComputer(move) {
var fPX = ((move >> 9) & 7);
var fPY = ((move >> 6) & 7);
var lPX = ((move >> 3) & 7);
var lPY = (move & 7);
var tgt = chessBoard[lPX][lPY];
if (((tgt & 1) == SIDE_PLAYER) && (tgt != VOID)) {
_root.writeHistory("<FONT COLOR='#00FF00'>Capture!</FONT>");
_root.capturedWhite++;
_root["capturedpieceb_" + _root.capturedWhite].showPiece(tgt);
}
chessBoard[lPX][lPY] = chessBoard[fPX][fPY];
chessBoard[fPX][fPY] = VOID;
_root[(("piece_" + lPX) + "_") + lPY].showPiece(chessBoard[lPX][lPY]);
_root[(("piece_" + fPX) + "_") + fPY].showPiece(VOID);
if (SIDE_COMPUTER == 0) {
ourPawn = PAWN_B;
ourQueen = QUEEN_B;
ourPromotion = 7;
} else {
ourPawn = PAWN_W;
ourQueen = QUEEN_W;
ourPromotion = 0;
}
if ((lPX == ourPromotion) && (chessBoard[lPX][lPY] == ourPawn)) {
_root.writeHistory("Promotion to queen");
chessBoard[lPX][lPY] = ourQueen;
_root[(("piece_" + lPX) + "_") + lPY].showPiece(ourQueen);
}
displayMove(move, SIDE_COMPUTER);
movePlayer();
}
function resetAllSelection() {
var i = 0;
while (i < 8) {
var j = 0;
while (j < 8) {
if ((chessBoard[i][j] == VOID) || ((chessBoard[i][j] & 1) == SIDE_COMPUTER)) {
_root[(("piece_" + i) + "_") + j].marker.gotoAndStop("disabled");
} else {
_root[(("piece_" + i) + "_") + j].marker.gotoAndStop("normal");
}
j++;
}
i++;
}
}
function select(row, col, real) {
resetAllSelection();
var possibleMoves = calculateMoves(row, col, SIDE_PLAYER);
if (SIDE_PLAYER == 1) {
ourKing = KING_W;
ourRook = ROOK_W;
} else {
ourKing = KING_B;
ourRook = ROOK_B;
}
if (SIDE_PLAYER_possibleRocade && (real != true)) {
if (chessBoard[row][col] == ourKing) {
var k = col;
var adv = true;
while (adv) {
k++;
if (chessBoard[row][k] != VOID) {
if (chessBoard[row][k] == ourRook) {
if (verifyKingState((((row << 9) | (col << 6)) | (row << 3)) | (col + 2), SIDE_PLAYER)) {
possibleMoves[possibleMoves.length] = (((row << 9) | (col << 6)) | (row << 3)) | k;
}
}
adv = false;
}
}
k = col;
adv = true;
while (adv) {
k--;
if (chessBoard[row][k] != VOID) {
if (chessBoard[row][k] == ourRook) {
if (verifyKingState((((row << 9) | (col << 6)) | (row << 3)) | (col - 2), SIDE_PLAYER)) {
possibleMoves[possibleMoves.length] = (((row << 9) | (col << 6)) | (row << 3)) | k;
}
}
adv = false;
}
}
}
}
var validMoves = new Array();
var i = 0;
while (i < possibleMoves.length) {
if (verifyKingState(possibleMoves[i], SIDE_PLAYER)) {
validMoves[validMoves.length] = possibleMoves[i];
}
i++;
}
if (real != true) {
var i = 0;
while (i < validMoves.length) {
_root[(("piece_" + ((validMoves[i] >> 3) & 7)) + "_") + (validMoves[i] & 7)].marker.gotoAndStop("selectedTo");
i++;
}
pieceSelected = _root[(("piece_" + row) + "_") + col];
} else {
return(validMoves.length);
}
}
function kingInChess(rowKing, colKing, side) {
if (side == SIDE_COMPUTER) {
SIDE_COMPUTER_possibleRocade = false;
} else {
SIDE_PLAYER_possibleRocade = false;
}
_root.debug2 = "718";
if (side == SIDE_PLAYER) {
_root.writeHistory("<FONT COLOR='#FF0000'>You are in chess!</FONT>");
} else {
_root.writeHistory("<FONT COLOR='#FF0000'>Comp is in chess!</FONT>");
}
var possibleMoves;
var isChessMat = true;
var i = 0;
while (i < 8) {
var j = 0;
while (j < 8) {
if (((chessBoard[i][j] & 1) == side) && (chessBoard[i][j] != VOID)) {
possibleMoves = calculateMoves(i, j, side);
disabled = true;
var k = 0;
while (k < possibleMoves.length) {
if (verifyKingState(possibleMoves[k], side)) {
isChessMat = false;
}
k++;
}
}
j++;
}
i++;
}
if (isChessMat) {
loose(side);
}
}
function loose(side) {
if (side == SIDE_COMPUTER) {
computerLoose();
} else {
playerLoose();
}
}
function playerLoose() {
invalidateAll();
_root.writeHistory("<FONT COLOR='#0099CC'>You loose. Checkmate.</FONT>");
_root.messages.gotoAndStop(3);
}
function search(side, depth, alpha, beta) {
var bestScore = (-INFINITY);
var aM = new Array();
var capturedPiece = null;
var moveScore;
var compMoves;
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 8) {
if (((chessBoard[i][j] & 1) == side) && (chessBoard[i][j] != VOID)) {
aM = aM.concat(calculateMoves(i, j, side));
}
}
}
var i = -1;
while ((++i) < aM.length) {
capturedPiece = do_move(aM[i], side);
if (depth == 0) {
moveScore = ((side == SIDE_COMPUTER) ? (computerScore) : (playerScore));
} else {
moveScore = -search(getOpponent(side), depth - 1, -1 * beta, -1 * alpha);
}
undo_move(aM[i], side, capturedPiece);
if (bestScore < moveScore) {
bestScore = moveScore;
}
if (alpha < bestScore) {
alpha = bestScore;
}
if (alpha >= beta) {
return(alpha);
}
}
return(bestScore);
}
function shuffle(collection) {
var nCollection = new Array();
var value;
var val;
while (collection.length != 0) {
val = Math.round(Math.random() * (collection.length - 1));
value = collection[val];
collection.splice(val, 1);
nCollection.push(value);
}
delete collection;
return(nCollection);
}
function getOpponent(side) {
if (side == SIDE_PLAYER) {
return(SIDE_COMPUTER);
}
return(SIDE_PLAYER);
}
function undo_move(move, side, pieceCaptured) {
var fPX = ((move >> 9) & 7);
var fPY = ((move >> 6) & 7);
var lPX = ((move >> 3) & 7);
var lPY = (move & 7);
chessBoard[fPX][fPY] = chessBoard[lPX][lPY];
if (pieceCaptured != VOID) {
chessBoard[lPX][lPY] = pieceCaptured;
if (side == SIDE_COMPUTER) {
playerScore = playerScore + (chessBoard[lPX][lPY] >> 1);
computerScore = computerScore - (chessBoard[lPX][lPY] >> 1);
} else {
playerScore = playerScore - (chessBoard[lPX][lPY] >> 1);
computerScore = computerScore + (chessBoard[lPX][lPY] >> 1);
}
} else {
chessBoard[lPX][lPY] = VOID;
}
}
function verifyKingState(move, side) {
var capturedPiece;
var compMoves;
var row;
var col;
capturedPiece = do_move(move, side);
var i = 0;
while (i < 8) {
var j = 0;
while (j < 8) {
if (((chessBoard[i][j] & 1) == getOpponent(side)) && (chessBoard[i][j] != VOID)) {
compMoves = calculateMoves(i, j, getOpponent(side));
var k = 0;
if (SIDE_PLAYER == 1) {
var ourKing = KING_W;
var opponentKing = KING_B;
} else {
var ourKing = KING_B;
var opponentKing = KING_W;
}
while (k < compMoves.length) {
row = (compMoves[k] >> 3) & 7;
col = compMoves[k] & 7;
if (((chessBoard[row][col] == ourKing) && (side == SIDE_PLAYER)) || ((chessBoard[row][col] == opponentKing) && (side == SIDE_COMPUTER))) {
undo_move(move, side, capturedPiece);
return(false);
}
k++;
}
}
j++;
}
i++;
}
undo_move(move, side, capturedPiece);
return(true);
}
progressbar._visible = false;
MAXDEPTH = 1;
VOID = -1;
PAWN_W = 5;
KNIGHT_W = 13;
ROOK_W = 21;
BISSHOP_W = 17;
QUEEN_W = 29;
KING_W = 2001;
PAWN_B = 4;
KNIGHT_B = 12;
ROOK_B = 20;
BISSHOP_B = 16;
QUEEN_B = 28;
KING_B = 4000;
SIDE_COMPUTER = 0;
SIDE_PLAYER = 1;
letters = new Array("a", "b", "c", "d", "e", "f", "g", "h");
numbers = new Array("1", "2", "3", "4", "5", "6", "7", "8");
TWOPLAYERS_MODE = false;
SIDE_COMPUTER_possibleRocade = true;
SIDE_PLAYER_possibleRocade = true;
pawnRules = new MovementRules();
pawnRules.isPawn = true;
pawnRules.up = 1;
knightRules = new MovementRules();
knightRules.isKnight = true;
rookRules = new MovementRules();
rookRules.up = 8;
rookRules.down = 8;
rookRules.left = 8;
rookRules.right = 8;
bisshopRules = new MovementRules();
bisshopRules.up_left = 8;
bisshopRules.up_right = 8;
bisshopRules.down_left = 8;
bisshopRules.down_right = 8;
queenRules = new MovementRules();
queenRules.up = 8;
queenRules.down = 8;
queenRules.left = 8;
queenRules.right = 8;
queenRules.up_left = 8;
queenRules.up_right = 8;
queenRules.down_left = 8;
queenRules.down_right = 8;
kingRules = new MovementRules();
kingRules.up = 1;
kingRules.down = 1;
kingRules.left = 1;
kingRules.right = 1;
kingRules.up_left = 1;
kingRules.up_right = 1;
kingRules.down_left = 1;
kingRules.down_right = 1;
poMo = new Array();
stop();
Frame 7
if (false) {
}
messages.gotoAndStop("compTurn");
computerScore = 0;
playerScore = 0;
var i = -1;
while ((++i) < 8) {
var j = -1;
while ((++j) < 8) {
if (chessBoard[i][j] != VOID) {
if (chessBoard[i][j] & (1 == SIDE_COMPUTER)) {
computerScore = computerScore + (chessBoard[i][j] >> 1);
playerScore = playerScore - (chessBoard[i][j] >> 1);
} else if (chessBoard[i][j] & (1 == SIDE_PLAYER)) {
computerScore = computerScore - (chessBoard[i][j] >> 1);
playerScore = playerScore + (chessBoard[i][j] >> 1);
}
}
}
}
play();
Frame 8
if (false) {
}
computerScore = 0;
INFINITY = 10000000 /* 0x989680 */;
s = getTimer();
trace("my turn");
alpha = -INFINITY;
beta = INFINITY;
bestMove = null;
bestScore = -INFINITY;
allPossibleMoves = new Array();
capturedPiece = null;
side = SIDE_COMPUTER;
depth = MAXDEPTH;
var i = 0;
while (i < 8) {
var j = 0;
while (j < 8) {
if (((chessBoard[i][j] & 1) == side) && (chessBoard[i][j] != VOID)) {
compMoves = calculateMoves(i, j, side);
allPossibleMoves = allPossibleMoves.concat(compMoves);
}
j++;
}
i++;
}
allPossibleMoves = shuffle(allPossibleMoves);
trace(allPossibleMoves);
index = 0;
Frame 9
if (false) {
}
if (index < allPossibleMoves.length) {
trace("calculated moves: " + index);
trace("total possible moves:" + (allPossibleMoves.length - 1));
if (index != 0) {
if (progressbar._visible != true) {
progressbar._visible = true;
}
var p = (100 / ((allPossibleMoves.length - 1) / index));
progressbar.progress._xscale = p;
progressbar.percent = int(p) + "%";
}
capturedPiece = do_move(allPossibleMoves[index], side);
moveScore = -search(getOpponent(side), depth, -1 * beta, -1 * alpha);
} else {
gotoAndPlay (11);
}
Frame 10
if (false) {
}
undo_move(allPossibleMoves[index], side, capturedPiece);
if (bestScore < moveScore) {
bestScore = moveScore;
bestMove = allPossibleMoves[index];
}
if (alpha < bestScore) {
alpha = bestScore;
}
if (alpha >= beta) {
gotoAndPlay (11);
}
index++;
gotoAndPlay(_currentframe - 1);
Frame 11
if (false) {
}
delete allPossibleMoves;
trace("time " + (getTimer() - s));
isPat = checkChessState(SIDE_COMPUTER);
tempP = do_move(bestMove, SIDE_COMPUTER);
isNotMat = checkChessState(SIDE_COMPUTER);
undo_move(bestMove, SIDE_COMPUTER, tempP);
if (bestMove == null) {
_root.messages.gotoAndStop("Pat");
} else if (isNotMat) {
moveRealComputer(bestMove);
messages.gotoAndStop(1);
} else if (isPat) {
_root.messages.gotoAndStop("Pat");
} else {
computerLoose();
}
progressbar._visible = false;
stop();
Symbol 1 MovieClip [FUIComponentSymbol] Frame 1
#initclip 1
function FUIComponentClass() {
this.init();
}
FUIComponentClass.prototype = new MovieClip();
FUIComponentClass.prototype.init = function () {
this.enable = true;
this.focused = false;
this.useHandCursor = false;
this._accImpl = new Object();
this._accImpl.stub = true;
this.styleTable = new Array();
if (_global.globalStyleFormat == undefined) {
_global.globalStyleFormat = new FStyleFormat();
globalStyleFormat.isGlobal = true;
_global._focusControl = new Object();
_global._focusControl.onSetFocus = function (oldFocus, newFocus) {
oldFocus.myOnKillFocus();
newFocus.myOnSetFocus();
};
Selection.addListener(_global._focusControl);
}
if (this._name != undefined) {
this._focusrect = false;
this.tabEnabled = true;
this.focusEnabled = true;
this.tabChildren = false;
this.tabFocused = true;
if (this.hostStyle == undefined) {
globalStyleFormat.addListener(this);
} else {
this.styleTable = this.hostStyle;
}
this.deadPreview._visible = false;
this.deadPreview._width = (this.deadPreview._height = 1);
this.methodTable = new Object();
this.keyListener = new Object();
this.keyListener.controller = this;
this.keyListener.onKeyDown = function () {
this.controller.myOnKeyDown();
};
this.keyListener.onKeyUp = function () {
this.controller.myOnKeyUp();
};
for (var i in this.styleFormat_prm) {
this.setStyleProperty(i, this.styleFormat_prm[i]);
}
}
};
FUIComponentClass.prototype.setEnabled = function (enabledFlag) {
this.enable = ((arguments.length > 0) ? (enabledFlag) : true);
this.tabEnabled = (this.focusEnabled = enabledFlag);
if ((!this.enable) && (this.focused)) {
Selection.setFocus(undefined);
}
};
FUIComponentClass.prototype.getEnabled = function () {
return(this.enable);
};
FUIComponentClass.prototype.setSize = function (w, h) {
this.width = w;
this.height = h;
this.focusRect.removeMovieClip();
};
FUIComponentClass.prototype.setChangeHandler = function (chng, obj) {
this.handlerObj = ((obj == undefined) ? (this._parent) : (obj));
this.changeHandler = chng;
};
FUIComponentClass.prototype.invalidate = function (methodName) {
this.methodTable[methodName] = true;
this.onEnterFrame = this.cleanUI;
};
FUIComponentClass.prototype.cleanUI = function () {
if (this.methodTable.setSize) {
this.setSize(this.width, this.height);
} else {
this.cleanUINotSize();
}
this.methodTable = new Object();
delete this.onEnterFrame;
};
FUIComponentClass.prototype.cleanUINotSize = function () {
for (var funct in this.methodTable) {
this[funct]();
}
};
FUIComponentClass.prototype.drawRect = function (x, y, w, h) {
var inner = this.styleTable.focusRectInner.value;
var outer = this.styleTable.focusRectOuter.value;
if (inner == undefined) {
inner = 16777215 /* 0xFFFFFF */;
}
if (outer == undefined) {
outer = 0;
}
this.createEmptyMovieClip("focusRect", 1000);
this.focusRect.controller = this;
this.focusRect.lineStyle(1, outer);
this.focusRect.moveTo(x, y);
this.focusRect.lineTo(x + w, y);
this.focusRect.lineTo(x + w, y + h);
this.focusRect.lineTo(x, y + h);
this.focusRect.lineTo(x, y);
this.focusRect.lineStyle(1, inner);
this.focusRect.moveTo(x + 1, y + 1);
this.focusRect.lineTo((x + w) - 1, y + 1);
this.focusRect.lineTo((x + w) - 1, (y + h) - 1);
this.focusRect.lineTo(x + 1, (y + h) - 1);
this.focusRect.lineTo(x + 1, y + 1);
};
FUIComponentClass.prototype.pressFocus = function () {
this.tabFocused = false;
this.focusRect.removeMovieClip();
Selection.setFocus(this);
};
FUIComponentClass.prototype.drawFocusRect = function () {
this.drawRect(-2, -2, this.width + 4, this.height + 4);
};
FUIComponentClass.prototype.myOnSetFocus = function () {
this.focused = true;
Key.addListener(this.keyListener);
if (this.tabFocused) {
this.drawFocusRect();
}
};
FUIComponentClass.prototype.myOnKillFocus = function () {
this.tabFocused = true;
this.focused = false;
this.focusRect.removeMovieClip();
Key.removeListener(this.keyListener);
};
FUIComponentClass.prototype.executeCallBack = function () {
this.handlerObj[this.changeHandler](this);
};
FUIComponentClass.prototype.updateStyleProperty = function (styleFormat, propName) {
this.setStyleProperty(propName, styleFormat[propName], styleFormat.isGlobal);
};
FUIComponentClass.prototype.setStyleProperty = function (propName, value, isGlobal) {
if (value == "") {
return(undefined);
}
var tmpValue = parseInt(value);
if (!isNaN(tmpValue)) {
value = tmpValue;
}
var global = ((arguments.length > 2) ? (isGlobal) : false);
if (this.styleTable[propName] == undefined) {
this.styleTable[propName] = new Object();
this.styleTable[propName].useGlobal = true;
}
if (this.styleTable[propName].useGlobal || (!global)) {
this.styleTable[propName].value = value;
if (this.setCustomStyleProperty(propName, value)) {
} else if (propName == "embedFonts") {
this.invalidate("setSize");
} else if (propName.subString(0, 4) == "text") {
if (this.textStyle == undefined) {
this.textStyle = new TextFormat();
}
var textProp = propName.subString(4, propName.length);
this.textStyle[textProp] = value;
this.invalidate("setSize");
} else {
for (var j in this.styleTable[propName].coloredMCs) {
var myColor = new Color(this.styleTable[propName].coloredMCs[j]);
if (this.styleTable[propName].value == undefined) {
var myTObj = {ra:"100", rb:"0", ga:"100", gb:"0", ba:"100", bb:"0", aa:"100", ab:"0"};
myColor.setTransform(myTObj);
} else {
myColor.setRGB(value);
}
}
}
this.styleTable[propName].useGlobal = global;
}
};
FUIComponentClass.prototype.registerSkinElement = function (skinMCRef, propName) {
if (this.styleTable[propName] == undefined) {
this.styleTable[propName] = new Object();
this.styleTable[propName].useGlobal = true;
}
if (this.styleTable[propName].coloredMCs == undefined) {
this.styleTable[propName].coloredMCs = new Object();
}
this.styleTable[propName].coloredMCs[skinMCRef] = skinMCRef;
if (this.styleTable[propName].value != undefined) {
var myColor = new Color(skinMCRef);
myColor.setRGB(this.styleTable[propName].value);
}
};
_global.FStyleFormat = function () {
this.nonStyles = {listeners:true, isGlobal:true, isAStyle:true, addListener:true, removeListener:true, nonStyles:true, applyChanges:true};
this.listeners = new Object();
this.isGlobal = false;
if (arguments.length > 0) {
for (var i in arguments[0]) {
this[i] = arguments[0][i];
}
}
};
_global.FStyleFormat.prototype = new Object();
FStyleFormat.prototype.addListener = function () {
var arg = 0;
while (arg < arguments.length) {
var mcRef = arguments[arg];
this.listeners[arguments[arg]] = mcRef;
for (var i in this) {
if (this.isAStyle(i)) {
mcRef.updateStyleProperty(this, i.toString());
}
}
arg++;
}
};
FStyleFormat.prototype.removeListener = function (component) {
this.listeners[component] = undefined;
for (var prop in this) {
if (this.isAStyle(prop)) {
if (component.styleTable[prop].useGlobal == this.isGlobal) {
component.styleTable[prop].useGlobal = true;
var value = (this.isGlobal ? undefined : (globalStyleFormat[prop]));
component.setStyleProperty(prop, value, true);
}
}
}
};
FStyleFormat.prototype.applyChanges = function () {
var count = 0;
for (var i in this.listeners) {
var component = this.listeners[i];
if (arguments.length > 0) {
var j = 0;
while (j < arguments.length) {
if (this.isAStyle(arguments[j])) {
component.updateStyleProperty(this, arguments[j]);
}
j++;
}
} else {
for (var j in this) {
if (this.isAStyle(j)) {
component.updateStyleProperty(this, j.toString());
}
}
}
}
};
FStyleFormat.prototype.isAStyle = function (name) {
return((this.nonStyles[name] ? false : true));
};
#endinitclip
if (false) {
}
Symbol 14 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 24 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 33 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "foregroundDisabled");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 34 MovieClip [UpArrow] Frame 1
if (false) {
}
stop();
Symbol 34 MovieClip [UpArrow] Frame 2
if (false) {
}
stop();
Symbol 34 MovieClip [UpArrow] Frame 3
if (false) {
}
stop();
Symbol 41 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 48 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 53 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(highlight3D_mc, "highlight3D");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
Symbol 54 MovieClip [ScrollThumb] Frame 1
if (false) {
}
stop();
Symbol 62 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 70 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 78 MovieClip Frame 1
if (false) {
}
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "foregroundDisabled");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 79 MovieClip [DownArrow] Frame 1
if (false) {
}
stop();
Symbol 79 MovieClip [DownArrow] Frame 2
if (false) {
}
stop();
Symbol 79 MovieClip [DownArrow] Frame 3
if (false) {
}
stop();
Symbol 82 MovieClip Frame 1
if (false) {
}
var component = _parent;
component.registerSkinElement(track_mc, "scrollTrack");
Symbol 83 MovieClip [FScrollBarSymbol] Frame 1
#initclip 2
FScrollBarClass = function () {
if (this._height == 4) {
return(undefined);
}
this.init();
this.minPos = (this.maxPos = (this.pageSize = (this.largeScroll = 0)));
this.smallScroll = 1;
this.width = (this.horizontal ? (this._width) : (this._height));
this._xscale = (this._yscale = 100);
this.setScrollPosition(0);
this.tabEnabled = false;
if (this._targetInstanceName.length > 0) {
this.setScrollTarget(this._parent[this._targetInstanceName]);
}
this.tabChildren = false;
this.setSize(this.width);
};
FScrollBarClass.prototype = new FUIComponentClass();
FScrollBarClass.prototype.setHorizontal = function (flag) {
if (this.horizontal && (!flag)) {
this._xscale = 100;
this._rotation = 0;
} else if (flag && (!this.horizontal)) {
this._xscale = -100;
this._rotation = -90;
}
this.horizontal = flag;
};
FScrollBarClass.prototype.setScrollProperties = function (pSize, mnPos, mxPos) {
if (!this.enable) {
return(undefined);
}
this.pageSize = pSize;
this.minPos = Math.max(mnPos, 0);
this.maxPos = Math.max(mxPos, 0);
this.scrollPosition = Math.max(this.minPos, this.scrollPosition);
this.scrollPosition = Math.min(this.maxPos, this.scrollPosition);
if ((this.maxPos - this.minPos) <= 0) {
this.scrollThumb_mc.removeMovieClip();
this.upArrow_mc.gotoAndStop(3);
this.downArrow_mc.gotoAndStop(3);
this.downArrow_mc.onPress = (this.downArrow_mc.onRelease = (this.downArrow_mc.onDragOut = null));
this.upArrow_mc.onPress = (this.upArrow_mc.onRelease = (this.upArrow_mc.onDragOut = null));
this.scrollTrack_mc.onPress = (this.scrollTrack_mc.onRelease = null);
this.scrollTrack_mc.onDragOut = (this.scrollTrack_mc.onRollOut = null);
this.scrollTrack_mc.useHandCursor = false;
} else {
var tmp = this.getScrollPosition();
this.upArrow_mc.gotoAndStop(1);
this.downArrow_mc.gotoAndStop(1);
this.upArrow_mc.onPress = (this.upArrow_mc.onDragOver = this.startUpScroller);
this.upArrow_mc.onRelease = (this.upArrow_mc.onDragOut = this.stopScrolling);
this.downArrow_mc.onPress = (this.downArrow_mc.onDragOver = this.startDownScroller);
this.downArrow_mc.onRelease = (this.downArrow_mc.onDragOut = this.stopScrolling);
this.scrollTrack_mc.onPress = (this.scrollTrack_mc.onDragOver = this.startTrackScroller);
this.scrollTrack_mc.onRelease = this.stopScrolling;
this.scrollTrack_mc.onDragOut = this.stopScrolling;
this.scrollTrack_mc.onRollOut = this.stopScrolling;
this.scrollTrack_mc.useHandCursor = false;
this.attachMovie("ScrollThumb", "scrollThumb_mc", 3);
this.scrollThumb_mc._x = 0;
this.scrollThumb_mc._y = this.upArrow_mc._height;
this.scrollThumb_mc.onPress = this.startDragThumb;
this.scrollThumb_mc.controller = this;
this.scrollThumb_mc.onRelease = (this.scrollThumb_mc.onReleaseOutside = this.stopDragThumb);
this.scrollThumb_mc.useHandCursor = false;
this.thumbHeight = (this.pageSize / ((this.maxPos - this.minPos) + this.pageSize)) * this.trackSize;
this.thumbMid_mc = this.scrollThumb_mc.mc_sliderMid;
this.thumbTop_mc = this.scrollThumb_mc.mc_sliderTop;
this.thumbBot_mc = this.scrollThumb_mc.mc_sliderBot;
this.thumbHeight = Math.max(this.thumbHeight, 6);
this.midHeight = (this.thumbHeight - this.thumbTop_mc._height) - this.thumbBot_mc._height;
this.thumbMid_mc._yScale = (this.midHeight * 100) / this.thumbMid_mc._height;
this.thumbMid_mc._y = this.thumbTop_mc._height;
this.thumbBot_mc._y = this.thumbTop_mc._height + this.midHeight;
this.scrollTop = this.scrollThumb_mc._y;
this.trackHeight = this.trackSize - this.thumbHeight;
this.scrollBot = this.trackHeight + this.scrollTop;
tmp = Math.min(tmp, this.maxPos);
this.setScrollPosition(Math.max(tmp, this.minPos));
}
};
FScrollBarClass.prototype.getScrollPosition = function () {
return(this.scrollPosition);
};
FScrollBarClass.prototype.setScrollPosition = function (pos) {
this.scrollPosition = pos;
if (this.scrollThumb_mc != undefined) {
pos = Math.min(pos, this.maxPos);
pos = Math.max(pos, this.minPos);
}
this.scrollThumb_mc._y = (((pos - this.minPos) * this.trackHeight) / (this.maxPos - this.minPos)) + this.scrollTop;
this.executeCallBack();
};
FScrollBarClass.prototype.setLargeScroll = function (lScroll) {
this.largeScroll = lScroll;
};
FScrollBarClass.prototype.setSmallScroll = function (sScroll) {
this.smallScroll = sScroll;
};
FScrollBarClass.prototype.setEnabled = function (enabledFlag) {
var wasEnabled = this.enable;
if (enabledFlag && (!wasEnabled)) {
this.enable = enabledFlag;
if (this.textField != undefined) {
this.setScrollTarget(this.textField);
} else {
this.setScrollProperties(this.pageSize, this.cachedMinPos, this.cachedMaxPos);
this.setScrollPosition(this.cachedPos);
}
this.clickFilter = undefined;
} else if ((!enabledFlag) && (wasEnabled)) {
this.textField.removeListener(this);
this.cachedPos = this.getScrollPosition();
this.cachedMinPos = this.minPos;
this.cachedMaxPos = this.maxPos;
if (this.clickFilter == undefined) {
this.setScrollProperties(this.pageSize, 0, 0);
} else {
this.clickFilter = true;
}
this.enable = enabledFlag;
}
};
FScrollBarClass.prototype.setSize = function (hgt) {
if (this._height == 1) {
return(undefined);
}
this.width = hgt;
this.scrollTrack_mc._yscale = 100;
this.scrollTrack_mc._yscale = (100 * this.width) / this.scrollTrack_mc._height;
if (this.upArrow_mc == undefined) {
this.attachMovie("UpArrow", "upArrow_mc", 1);
this.attachMovie("DownArrow", "downArrow_mc", 2);
this.downArrow_mc.controller = (this.upArrow_mc.controller = this);
this.upArrow_mc.useHandCursor = (this.downArrow_mc.useHandCursor = false);
this.upArrow_mc._x = (this.upArrow_mc._y = 0);
this.downArrow_mc._x = 0;
}
this.scrollTrack_mc.controller = this;
this.downArrow_mc._y = this.width - this.downArrow_mc._height;
this.trackSize = this.width - (2 * this.downArrow_mc._height);
if (this.textField != undefined) {
this.onTextChanged();
} else {
this.setScrollProperties(this.pageSize, this.minPos, this.maxPos);
}
};
FScrollBarClass.prototype.scrollIt = function (inc, mode) {
var delt = this.smallScroll;
if (inc != "one") {
delt = ((this.largeScroll == 0) ? (this.pageSize) : (this.largeScroll));
}
var newPos = (this.getScrollPosition() + (mode * delt));
if (newPos > this.maxPos) {
newPos = this.maxPos;
} else if (newPos < this.minPos) {
newPos = this.minPos;
}
this.setScrollPosition(newPos);
};
FScrollBarClass.prototype.startDragThumb = function () {
this.lastY = this._ymouse;
this.onMouseMove = this.controller.dragThumb;
};
FScrollBarClass.prototype.dragThumb = function () {
this.scrollMove = this._ymouse - this.lastY;
this.scrollMove = this.scrollMove + this._y;
if (this.scrollMove < this.controller.scrollTop) {
this.scrollMove = this.controller.scrollTop;
} else if (this.scrollMove > this.controller.scrollBot) {
this.scrollMove = this.controller.scrollBot;
}
this._y = this.scrollMove;
var c = this.controller;
c.scrollPosition = Math.round(((c.maxPos - c.minPos) * (this._y - c.scrollTop)) / c.trackHeight) + c.minPos;
this.controller.isScrolling = true;
updateAfterEvent();
this.controller.executeCallBack();
};
FScrollBarClass.prototype.stopDragThumb = function () {
this.controller.isScrolling = false;
this.onMouseMove = null;
};
FScrollBarClass.prototype.startTrackScroller = function () {
this.controller.trackScroller();
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "page", -1);
};
FScrollBarClass.prototype.scrollInterval = function (inc, mode) {
clearInterval(this.scrolling);
if (inc == "page") {
this.trackScroller();
} else {
this.scrollIt(inc, mode);
}
this.scrolling = setInterval(this, "scrollInterval", 35, inc, mode);
};
FScrollBarClass.prototype.trackScroller = function () {
if ((this.scrollThumb_mc._y + this.thumbHeight) < this._ymouse) {
this.scrollIt("page", 1);
} else if (this.scrollThumb_mc._y > this._ymouse) {
this.scrollIt("page", -1);
}
};
FScrollBarClass.prototype.stopScrolling = function () {
this.controller.downArrow_mc.gotoAndStop(1);
this.controller.upArrow_mc.gotoAndStop(1);
clearInterval(this.controller.scrolling);
};
FScrollBarClass.prototype.startUpScroller = function () {
this.controller.upArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one", -1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", -1);
};
FScrollBarClass.prototype.startDownScroller = function () {
this.controller.downArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one", 1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", 1);
};
FScrollBarClass.prototype.setScrollTarget = function (tF) {
if (tF == undefined) {
this.textField.removeListener(this);
delete this.textField[(this.horizontal ? "hScroller" : "vScroller")];
if ((this.textField.hScroller != undefined) && (this.textField.vScroller != undefined)) {
this.textField.unwatch("text");
this.textField.unwatch("htmltext");
}
}
this.textField = undefined;
if (!(tF instanceof TextField)) {
return(undefined);
}
this.textField = tF;
this.textField[(this.horizontal ? "hScroller" : "vScroller")] = this;
this.onTextChanged();
this.onChanged = function () {
this.onTextChanged();
};
this.onScroller = function () {
if (!this.isScrolling) {
if (!this.horizontal) {
this.setScrollPosition(this.textField.scroll);
} else {
this.setScrollPosition(this.textField.hscroll);
}
}
};
this.textField.addListener(this);
this.textField.watch("text", this.callback);
this.textField.watch("htmlText", this.callback);
};
FScrollBarClass.prototype.callback = function (prop, oldVal, newVal) {
clearInterval(this.hScroller.synchScroll);
clearInterval(this.vScroller.synchScroll);
this.hScroller.synchScroll = setInterval(this.hScroller, "onTextChanged", 50);
this.vScroller.synchScroll = setInterval(this.vScroller, "onTextChanged", 50);
return(newVal);
};
FScrollBarClass.prototype.onTextChanged = function () {
if ((!this.enable) || (this.textField == undefined)) {
return(undefined);
}
clearInterval(this.synchScroll);
if (this.horizontal) {
var pos = this.textField.hscroll;
this.setScrollProperties(this.textField._width, 0, this.textField.maxhscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxhscroll));
} else {
var pos = this.textField.scroll;
var pageSize = (this.textField.bottomScroll - this.textField.scroll);
this.setScrollProperties(pageSize, 1, this.textField.maxscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxscroll));
}
};
FScrollBarClass.prototype.executeCallBack = function () {
if (this.textField == undefined) {
super.executeCallBack();
} else if (this.horizontal) {
this.textField.hscroll = this.getScrollPosition();
} else {
this.textField.scroll = this.getScrollPosition();
}
};
Object.registerClass("FScrollBarSymbol", FScrollBarClass);
#endinitclip
if (false) {
}
Symbol 88 MovieClip Frame 1
if (false) {
}
stop();
Symbol 88 MovieClip Frame 2
if (false) {
}
stop();
Symbol 91 Button
on (release) {
if (false) {
}
over.gotoAndStop(1);
_root.select(this._parent.row, this._parent.col);
gotoAndStop (4);
}
on (rollOver) {
if (false) {
}
over.gotoAndStop(2);
}
on (rollOut) {
if (false) {
}
over.gotoAndStop(1);
}
Symbol 93 MovieClip Frame 1
if (false) {
}
stop();
Symbol 94 Button
on (release) {
if (false) {
}
_root.moveRealPlayer((((_root.pieceSelected.row << 9) | (_root.pieceSelected.col << 6)) | (this._parent.row << 3)) | this._parent.col, _root.SIDE_PLAYER);
}
Symbol 95 Button
on (release) {
if (false) {
}
_root.deselect(this._parent);
_root.gotoAndStop("normal");
}
Symbol 96 MovieClip Frame 1
if (false) {
}
stop();
Symbol 96 MovieClip Frame 2
if (false) {
}
stop();
Symbol 96 MovieClip Frame 3
if (false) {
}
stop();
Symbol 96 MovieClip Frame 4
if (false) {
}
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 1
if (false) {
}
function showPiece(piece) {
if (piece == _root.VOID) {
gotoAndStop (1);
} else if (piece == _root.PAWN_W) {
gotoAndStop (2);
} else if (piece == _root.KNIGHT_W) {
gotoAndStop (3);
} else if (piece == _root.ROOK_W) {
gotoAndStop (4);
} else if (piece == _root.BISSHOP_W) {
gotoAndStop (5);
} else if (piece == _root.QUEEN_W) {
gotoAndStop (6);
} else if (piece == _root.KING_W) {
gotoAndStop (7);
} else if (piece == _root.PAWN_B) {
gotoAndStop (9);
} else if (piece == _root.KNIGHT_B) {
gotoAndStop (10);
} else if (piece == _root.ROOK_B) {
gotoAndStop (11);
} else if (piece == _root.BISSHOP_B) {
gotoAndStop (12);
} else if (piece == _root.QUEEN_B) {
gotoAndStop (13);
} else if (piece == _root.KING_B) {
gotoAndStop (14);
}
}
piece = "void";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 2
if (false) {
}
piece = "pawn_w";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 3
if (false) {
}
piece = "knight_w";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 4
if (false) {
}
piece = "rook_w";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 5
if (false) {
}
piece = "bisshop_w";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 6
if (false) {
}
piece = "queen_w";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 7
if (false) {
}
piece = "king_w";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 9
if (false) {
}
piece = "pawn_b";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 10
if (false) {
}
piece = "knight_b";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 11
if (false) {
}
piece = "rook_b";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 12
if (false) {
}
piece = "bisshop_b";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 13
if (false) {
}
piece = "queen_b";
stop();
Symbol 109 MovieClip [CHESSpiece] Frame 14
if (false) {
}
piece = "king_b";
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 1
if (false) {
}
function showPiece(piece) {
if (piece == _root.VOID) {
gotoAndStop (1);
} else if (piece == _root.PAWN_W) {
gotoAndStop (2);
} else if (piece == _root.KNIGHT_W) {
gotoAndStop (3);
} else if (piece == _root.ROOK_W) {
gotoAndStop (4);
} else if (piece == _root.BISSHOP_W) {
gotoAndStop (5);
} else if (piece == _root.QUEEN_W) {
gotoAndStop (6);
} else if (piece == _root.KING_W) {
gotoAndStop (7);
} else if (piece == _root.PAWN_B) {
gotoAndStop (9);
} else if (piece == _root.KNIGHT_B) {
gotoAndStop (10);
} else if (piece == _root.ROOK_B) {
gotoAndStop (11);
} else if (piece == _root.BISSHOP_B) {
gotoAndStop (12);
} else if (piece == _root.QUEEN_B) {
gotoAndStop (13);
} else if (piece == _root.KING_B) {
gotoAndStop (14);
}
}
piece = "void";
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 2
if (false) {
}
piece = "pawn_w";
lapiece.gotoAndStop("pawn_w");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 3
if (false) {
}
piece = "knight_w";
lapiece.gotoAndStop("knight_w");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 4
if (false) {
}
piece = "rook_w";
lapiece.gotoAndStop("rook_w");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 5
if (false) {
}
piece = "bisshop_w";
lapiece.gotoAndStop("bisshop_w");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 6
if (false) {
}
piece = "queen_w";
lapiece.gotoAndStop("queen_w");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 7
if (false) {
}
piece = "king_w";
lapiece.gotoAndStop("king_w");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 9
if (false) {
}
piece = "pawn_b";
lapiece.gotoAndStop("pawn_b");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 10
if (false) {
}
piece = "knight_b";
lapiece.gotoAndStop("knight_b");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 11
if (false) {
}
piece = "rook_b";
lapiece.gotoAndStop("rook_b");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 12
if (false) {
}
piece = "bisshop_b";
lapiece.gotoAndStop("bisshop_b");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 13
if (false) {
}
piece = "queen_b";
lapiece.gotoAndStop("queen_b");
stop();
Symbol 110 MovieClip [CHESScarreBoard] Frame 14
if (false) {
}
piece = "king_b";
lapiece.gotoAndStop("king_b");
stop();
Symbol 116 Button
on (release) {
if (false) {
}
_root.MAXDEPTH = 0;
_root.TWOPLAYERS_MODE = false;
_root.initChessBoard();
if ((_root.TWOPLAYERS_MODE == false) && (_root.SIDE_COMPUTER == 1)) {
_root.moveComputer();
} else {
_root.movePlayer();
}
_root.drawHistoryBar(195, 0, 120, 192);
_root.titleScreen.removeMovieClip();
}
on (rollOver) {
if (false) {
}
this.slow._alpha = 50;
}
on (rollOut) {
if (false) {
}
this.slow._alpha = 100;
}
Symbol 119 Button
on (release) {
if (false) {
}
_root.MAXDEPTH = 1;
_root.TWOPLAYERS_MODE = false;
_root.initChessBoard();
if ((_root.TWOPLAYERS_MODE == false) && (_root.SIDE_COMPUTER == 1)) {
_root.moveComputer();
} else {
_root.movePlayer();
}
_root.drawHistoryBar(195, 0, 120, 192);
_root.titleScreen.removeMovieClip();
}
on (rollOver) {
if (false) {
}
this.fast._alpha = 50;
}
on (rollOut) {
if (false) {
}
this.fast._alpha = 100;
}
Symbol 122 Button
on (release) {
if (false) {
}
_root.MAXDEPTH = 0;
_root.TWOPLAYERS_MODE = true;
_root.initChessBoard();
if ((_root.TWOPLAYERS_MODE == false) && (_root.SIDE_COMPUTER == 1)) {
_root.moveComputer();
} else {
_root.movePlayer();
}
_root.drawHistoryBar(195, 0, 120, 192);
_root.titleScreen.removeMovieClip();
}
on (rollOver) {
if (false) {
}
this.two._alpha = 50;
}
on (rollOut) {
if (false) {
}
this.two._alpha = 100;
}
Symbol 135 MovieClip Frame 1
if (false) {
}
stop();
Symbol 135 MovieClip Frame 2
if (false) {
}
stop();
Symbol 135 MovieClip Frame 3
if (false) {
}
stop();
Symbol 135 MovieClip Frame 4
if (false) {
}
stop();
Symbol 135 MovieClip Frame 5
if (false) {
}
stop();
Symbol 135 MovieClip Frame 6
if (false) {
}
stop();
Symbol 135 MovieClip Frame 7
if (false) {
}
stop();
Symbol 135 MovieClip Frame 10
if (false) {
}
stop();