[COLOR=#000000][FONT=verdana]Hey everyone, Im creating a tic tac toe game using AS3 and I got the basic board down and placement I just can’t figure out how to track who won I tried different tutorials but its not the same for my code. Im trying to make it as simple as possible. Here is the code :[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]package [/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]import flash.display.Sprite;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]import flash.events.MouseEvent;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]public class TicTacToeMain extends Sprite[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var ticTiles:Array = new Array(9);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var xTurn:Boolean = true;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var oTurn:Boolean = true;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var combos:Array = new Array(new Array(0, 1, 2), new Array(3, 4, 5), new Array(6, 7, 8),[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]new Array(0, 3, 6), new Array(1, 4, 7), new Array(2, 5, 8),[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]new Array(0, 4, 8), new Array(2, 4, 6))[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]public function TicTacToeMain():void[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]for (var i : int = 0; i < 3; i++)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]for (var j : int = 0; j < 3; j++)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var curTile:TicTile = new TicTile();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]curTile.x = j * curTile.width + j * 10 + curTile.width / 2 + 10;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]curTile.y = i * curTile.height + i * 10 + curTile.height / 2 + 10;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]addChild(curTile);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]curTile.addEventListener(MouseEvent.CLICK, takeTurn);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]curTile.overState = new xTile();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]ticTiles.push(curTile);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]public function takeTurn(evt:MouseEvent):void[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]evt.target.enabled = false;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]if (xTurn)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]evt.target.upState = new xTile();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]else[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]evt.target.upState = new oTile();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]xTurn = ! xTurn;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]for each (var tile:TicTile in ticTiles)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]if ( tile!= evt.target)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]tile.overState = (xTurn) ? new xTile() : new oTile();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]