School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,175 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,581 people online right now. Registration is fast and FREE... Join Now!




create a tic tac toe game

 

create a tic tac toe game

raviengg4

12 Dec, 2008 - 10:42 AM
Post #1

New D.I.C Head
*

Joined: 12 Dec, 2008
Posts: 1

var mouseSound:Sound = new Sound();
mouseSound.attachSound(”Ding”);
this.onMouseDown = function() {
mouseSound.start();
};
var startSound:Sound = new Sound();
startSound.attachSound(”tada1″);
this.onLoad = function() {
startSound.start();
};
// Drag a piece O.
O_mc.onPress = function() {
this.startDrag(false);
};
// When the O is placed on a square.
O_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
O_mc._visible = false;
}
};
// Drag a piece O.
O1_mc.onPress = function() {
this.startDrag(false);
};
// When the O is placed on a square.
O1_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
O1_mc._visible = false;
}
};
// Drag a piece O.
O2_mc.onPress = function() {
this.startDrag(false);
};
// When the O is placed on a square.
O2_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
O2_mc._visible = false;
}
};
// Drag a piece O.
O3_mc.onPress = function() {
this.startDrag(false);
};
// When the O is placed on a square.
O3_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
O3_mc._visible = false;
}
};
// Drag a piece O.
O4_mc.onPress = function() {
this.startDrag(false);
};
// When the O is placed on a square.
O4_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
O4_mc._visible = false;
}
};
// Drag a piece O.
O5_mc.onPress = function() {
this.startDrag(false);
};
// When the O is placed on a square.
O5_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
O5_mc._visible = false;
}
};
// Drag a piece X.
X_mc.onPress = function() {
this.startDrag(false);
};
// When the X is placed on a square.
X_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
X_mc._visible = false;
}
};
// Drag a piece X.
X1_mc.onPress = function() {
this.startDrag(false);
};
// When the X is placed on a square.
X1_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
X1_mc._visible = false;
}
};
// Drag a piece X.
X2_mc.onPress = function() {
this.startDrag(false);
};
// When the X is placed on a square.
X2_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
X2_mc._visible = false;
}
};
// Drag a piece X.
X3_mc.onPress = function() {
this.startDrag(false);
};
// When the X is placed on a square.
X3_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
X3_mc._visible = false;
}
};
// Drag a piece X.
X4_mc.onPress = function() {
this.startDrag(false);
};
// When the X is placed on a square.
X4_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
X4_mc._visible = false;
}
};
// Drag a piece X.
X5_mc.onPress = function() {
this.startDrag(false);
};
// When the X is placed on a square.
X5_mc.onRelease = function() {
this.stopDrag();
// Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == Board6_mc) {
X5_mc._visible = false;
}
};
var board_array = new Array();
// Create the array
for(var i = 0; i < total_turns; i )
{
array[i] = i;
}
var winning_array:Array = new Array();
// Contain winning combinations
winning_array =
[
// Vertical/Column Win
[0,1,2],
[3,4,5],
[6,7,8],
// Horizontal/Row Win
[0,3,6],
[1,4,7],
[2,5,8],
// Diagonal Win
[0,4,8],
[6,4,2]
]
// Compare the winning array to the player’s
for(var i = 0; i = 3)
for(var k = 0; k < player_array.length; k )
for(var j = 0; j < winning_combination.length; j )
if(player_array[k] == winning_combination[j])
match_counter ;
if(match_counter == 3)
is_match = true;
wc = winning_array[i];
break;
match_counter = 0;
function checkWin() {
if(display1.text == ” X ” && display2.text == ” X” && display3.text == ” X”) {
text_winner = ” Player X has Won”;
}
}

//in the release action of your button
checkWin();
function checkWin() {
if(display1.text == ” O ” && display2.text == ” X” && display3.text == ” X”) {
text_winner = ” Player O has Won”;
}
}

User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 1)

CyanBlue

RE: Create A Tic Tac Toe Game

12 Dec, 2008 - 01:18 PM
Post #2

D.I.C Head
Group Icon

Joined: 1 Sep, 2006
Posts: 156



Thanked: 5 times
My Contributions
I am not sure if I will ever need to create the game, but thanks for the code... wink2.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 07:14PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month