tictactoe. onclipevent (mouseup) { if (hittest(_root._xmouse, _root._ymouse, false) &&...
TRANSCRIPT
TicTacToe
• onClipEvent (mouseUp) {• if (hitTest(_root._xmouse, _root._ymouse, false) && _root.game_status !=
"end") {• if (String(this.txt_value.text) == "") {• this.txt_value.text = _root.userTime;• _root.CheckGame();• if (_root.userTime == "X") {• _root.userTime = "O";• } else if (_root.userTime == "O") {• _root.userTime = "X";• }• if (_root.game_status !="end"){• _root.txtStatus.text = "Time of Player
"+_root.userTime;• }• }• }• }
• userTime = "X";
• game_status = "play";
• txtStatus.text = "Time of Player "+userTime;
• function PieceX(col) {
• return xBase+col*xSpace;
• }
• function PieceY(row) {
• return yBase+row*ySpace;
• }
• numRows = 3;
• numCols = 3;
• numCells = numRows*numCols;
• xBase = box0._x;
• yBase = box0._y;
• xSpace = box0._width*1.07;
• ySpace = box0._height*1.07;
• var c = 1;
• var r = 0;
• for (var i = 1; i<numCells; i++) {• var name = "box"+i;• box0.duplicateMovieClip(name, i);• var newPiece = eval(name);• newPiece._x = PieceX(c);• newPiece._y = PieceY(r);• if (++c>=numCols) {• c = 0;• r++;• }• }
• function CheckGame() {• win0 = "0,1,2";• win1 = "3,4,5";• win2 = "6,7,8";• win3 = "0,3,6";• win4 = "1,4,7";• win5 = "2,5,8";• win6 = "0,4,8";• win7 = "2,4,6";• notWin = String(_root.box8.txt_value.text);• for (winCheck=0; winCheck<=7; winCheck++) {• winTemp = eval("win"+winCheck).split(",");• boxValue1 = String(eval("_root.box"+winTemp[0]).txt_value.text);• boxValue2 = String(eval("_root.box"+winTemp[1]).txt_value.text);• boxValue3 = String(eval("_root.box"+winTemp[2]).txt_value.text);• if (boxValue1 == boxValue2 && boxValue2 == boxValue3 &&
boxValue1 != "") {• txtStatus.text = "Player "+boxValue1+" win";• game_status = "end";• } else {• notWin += String(eval("box"+winCheck).txt_value.text);• if (notWin.length>=9) {• txtStatus.text = "NoWinNoLoose";• game_status = "end";• }• }• }• }• stop();