Frame 1
stop();
this.onEnterFrame = function () {
totb = this.getBytesTotal();
lodedb = this.getBytesLoaded();
if ((lodedb == totb) && (lodedb > 4)) {
delete this.onEnterFrame;
this.gotoAndStop("menu");
} else {
frameNumber = (lodedb * 100) / totb;
_root.loader.gotoAndStop(Math.round(frameNumber));
trace((Math.round(frameNumber) + "----") + _root.loader);
}
};
Frame 2
play();
help_mc._visible = 0;
Frame 8
stop();
Frame 9
stop();
_global.obj = new arrangeBoard(this.container);
_global.obj._Logic.shuffleandenable();
Symbol 21 MovieClip Frame 118
_root.gotoAndStop(2);
Symbol 94 MovieClip [__Packages.arrangeBoard] Frame 0
class arrangeBoard
{
var playerName, tableDataObj, _Logic, __board, tabArray, depth, tempmc, tmpball;
function arrangeBoard (board) {
playerName = "Player 1 ";
tableDataObj = new tableData();
_global.board = board;
_Logic = new gameLogic(playerName);
__board = board;
tabArray = ["a", "b", "c", "d", "e", "f", "g", "h"];
depth = 2;
setUp();
}
function setUp() {
var tempy;
var tempx;
tempx = 0;
tempy = 0;
var __Logic = _Logic;
var ballno = 1;
var i = 1;
while (i <= 8) {
tempx = 0;
var j = 1;
while (j <= 8) {
tempmc = __board.attachMovie("base_mc", (("mc_base$" + i) + "$") + j, __board.getNextHighestDepth());
tempmc._x = (tempmc._width * (j - 1)) + tempx;
tempmc._y = (tempmc._height * (i - 1)) + tempy;
tempmc.cellno = (i + "_") + j;
tempx = tempx + 6;
if (_global.row[i - 1].columns[j - 1].Bclr != "") {
tmpball = __board.attachMovie(_global.row[i - 1].columns[j - 1].Bclr, (_global.row[i - 1].columns[j - 1].Bclr + "") + ballno, __board.getNextHighestDepth());
ballno++;
tmpball._x = tempmc._x;
tmpball._y = tempmc._y;
_global.row[i - 1].columns[j - 1].ball = tmpball;
tmpball.cellno = _global.row[i - 1].columns[j - 1].id;
tmpball.btn_.onPress = function () {
this._parent.swapDepths(999);
trace("__Logic " + this._parent);
startDrag (this._parent);
__Logic.calculateline(this._parent.cellno);
};
tmpball.btn_.onRelease = (tmpball.btn_.onReleaseOutside = function () {
this._parent.swapDepths(999);
stopDrag();
__Logic.ifCanbePlaced(eval (this._parent._droptarget)._name, this._parent);
});
}
j++;
}
tempy = tempy + 5;
i++;
}
}
}
Symbol 95 MovieClip [__Packages.tableData] Frame 0
class tableData
{
var temtabData;
function tableData () {
_global.Bball = 12;
_global.Wball = 12;
_global.row = new Array();
temtabData = ["a", "b", "c", "d", "e", "f", "g", "h"];
var i = 0;
while (i <= 7) {
_global.row[i] = {totBall:0, columns:[]};
var j = 0;
while (j <= 7) {
_global.row[i].columns[j] = {rowNO:i, id:((i + 1) + "") + (j + 1), Bclr:"", ball:""};
j++;
}
i++;
}
_global.row[0].totBall = 6;
_global.row[7].totBall = 6;
var i = 1;
while (i <= 6) {
_global.row[0].columns[i].Bclr = "b";
_global.row[7].columns[i].Bclr = "b";
_global.row[i].totBall = 2;
_global.row[i].columns[0].Bclr = "w";
_global.row[i].columns[7].Bclr = "w";
i++;
}
}
}
Symbol 96 MovieClip [__Packages.gameLogic] Frame 0
class gameLogic
{
var currplayer, currclr, blackBalls, whiteBalls, movesnotfound, __checkeLisner, Linesarr, __validMoves, Rid, Cid, gameOver;
function gameLogic (lcurrplayer) {
currplayer = lcurrplayer;
currclr = ((currplayer == "Player 1 ") ? "w" : "b");
blackBalls = 12;
whiteBalls = 12;
movesnotfound = 0;
__checkeLisner = new Object();
Linesarr = new Array();
__validMoves = new Array();
}
function calculateline(cellid) {
var ball = new Array();
ball = cellid.split("");
Rid = Number(ball[0]);
Cid = Number(ball[1]);
RemoveHint();
Linesarr = new Array();
__validMoves = new Array();
validMoves("h");
}
function validMoves(drcton) {
switch (drcton) {
case "h" :
horizontalMoves();
return;
case "v" :
verticleMoves();
return;
case "rd" :
rightDaigonalMoves();
return;
case "ld" :
leftDaigonalMoves();
return;
case "final" :
sortValidMoves();
}
}
function horizontalMoves() {
var steps = _global.row[Rid - 1].totBall;
var newCell_1 = (Cid + steps);
var newCell_2 = (Cid - steps);
__validMoves[__validMoves.length] = (("mc_base$" + Rid) + "$") + newCell_1;
__validMoves[__validMoves.length] = (("mc_base$" + Rid) + "$") + newCell_2;
validMoves("v");
}
function verticleMoves() {
var steps = 0;
var i = 0;
while (i < 8) {
if (_global.row[i].columns[Cid - 1].Bclr != "") {
steps++;
}
i++;
}
var newCell_1 = (Rid + steps);
var newCell_2 = (Rid - steps);
__validMoves[__validMoves.length] = (("mc_base$" + newCell_1) + "$") + Cid;
__validMoves[__validMoves.length] = (("mc_base$" + newCell_2) + "$") + Cid;
validMoves("rd");
}
function rightDaigonalMoves() {
var lrid = Rid;
var lcid = Cid;
var steps = 0;
var k = 0;
while (k <= 8) {
if ((lrid >= 8) || (lcid <= 1)) {
break;
}
lrid++;
lcid--;
k++;
}
var j = lcid;
var i = lrid;
while (i >= 1) {
if (_global.row[i - 1].columns[j - 1].Bclr != "") {
steps++;
}
if ((i <= 1) || (j >= 8)) {
break;
}
j++;
i--;
}
var newCell_1 = (((Rid - steps) + "$") + (Cid + steps));
var newCell_2 = (((Rid + steps) + "$") + (Cid - steps));
__validMoves[__validMoves.length] = "mc_base$" + newCell_1;
__validMoves[__validMoves.length] = "mc_base$" + newCell_2;
validMoves("ld");
}
function leftDaigonalMoves() {
var lrid = Rid;
var lcid = Cid;
var steps = 0;
var k = 0;
while (k <= 8) {
if ((lrid >= 8) || (lcid >= 8)) {
break;
}
lrid++;
lcid++;
k++;
}
var j = lcid;
var i = lrid;
while (i >= 1) {
if (_global.row[i - 1].columns[j - 1].Bclr != "") {
steps++;
}
if ((i <= 1) || (j <= 1)) {
break;
}
j--;
i--;
}
var newCell_1 = (((Rid - steps) + "$") + (Cid - steps));
var newCell_2 = (((Rid + steps) + "$") + (Cid + steps));
__validMoves[__validMoves.length] = "mc_base$" + newCell_1;
__validMoves[__validMoves.length] = "mc_base$" + newCell_2;
validMoves("final");
}
function sortValidMoves() {
var newValidMoves = new Array();
var i = 0;
while (i < __validMoves.length) {
if (_global.obj.__board[__validMoves[i]] != undefined) {
newValidMoves[newValidMoves.length] = __validMoves[i];
}
i++;
}
var finalValidMoves = new Array();
var i = 0;
while (i < newValidMoves.length) {
var cidrid = newValidMoves[i].split("$");
var lrid = Number(cidrid[1]);
var lcid = Number(cidrid[2]);
trace("tracing only clr while sorting :" + currclr);
if ((_global.row[lrid - 1].columns[lcid - 1].Bclr == "") || (_global.row[lrid - 1].columns[lcid - 1].Bclr != currclr)) {
finalValidMoves[finalValidMoves.length] = newValidMoves[i];
}
i++;
}
__validMoves = finalValidMoves;
trace("tracing second Time :" + __validMoves);
showLines();
}
function showLines() {
var refMc = _global.obj.__board;
trace("_global.obj.__board : ARe u stupid or u just want to bug me ???" + _global.obj.__board);
var currcell = refMc[(("mc_base$" + Rid) + "$") + Cid];
var i = 0;
while (i < __validMoves.length) {
var newcell = refMc[__validMoves[i]];
var newmc = refMc.createEmptyMovieClip("Line" + i, refMc.getNextHighestDepth());
drawLine(newmc, currcell, newcell);
i++;
}
}
function drawLine(lnewmc, lcurrcell, lnewcell) {
var startX = (lcurrcell._x + (lcurrcell._width / 2));
var startY = (lcurrcell._y + (lcurrcell._height / 2));
var endX = (lnewcell._x + (lnewcell._width / 2));
var endY = (lnewcell._y + (lnewcell._height / 2));
with (lnewmc) {
lineStyle(2, 10027008, 100);
moveTo(startX, startY);
lineTo(endX, endY);
}
var circle = lnewmc.attachMovie("circle", "circle" + lnewmc, lnewmc.getNextHighestDepth());
circle._x = endX;
circle._y = endY;
Linesarr[Linesarr.length] = lnewmc;
Linesarr[Linesarr.length] = circle;
}
function ifCanbePlaced(drpt, ref) {
var isvalid;
var refmc = _global.obj.__board;
trace("drpt befor tracktarget : " + drpt);
drpt = tracktarget(drpt);
trace("drpt after tracktarget : " + drpt);
if (__validMoves.length <= 0) {
_global.obj.__board._parent.player.text = "No moves ..";
movesnotfound++;
if (movesnotfound == 2) {
_global.obj.__board._parent.player.text = "both of you dont have any moves !";
}
currclr = ((currclr == "w") ? "b" : "w");
shuffleandenable();
} else {
movesnotfound = 0;
var i = 0;
while (i < __validMoves.length) {
if (drpt == __validMoves[i]) {
var lridcid = __validMoves[i].split("$");
isvalid = true;
trace("ref :" + ref);
ref._x = refmc[__validMoves[i]]._x;
ref._y = refmc[__validMoves[i]]._y;
resetDataStructure(drpt, ref);
ref.cellno = lridcid[1] + lridcid[2];
_root.correct_audio_mc.gotoAndPlay(2);
RemoveHint();
break;
}
i++;
}
if (i == __validMoves.length) {
isvalid = false;
var currcell = ((("mc_base$" + Rid) + "$") + Cid);
ref._x = refmc[currcell]._x;
ref._y = refmc[currcell]._y;
}
}
}
function resetDataStructure(newcllref, oldcellref) {
var old_cidrid = oldcellref.cellno.split("");
((_global.row[old_cidrid[0] - 1].totBall > 0) ? ((_global.row[old_cidrid[0] - 1].totBall = _global.row[old_cidrid[0] - 1].totBall - 1)) : (trace("Decreased")));
var new_cidrid = newcllref.split("$");
((_global.row[new_cidrid[1] - 1].totBall < 8) ? ((_global.row[new_cidrid[1] - 1].totBall = _global.row[new_cidrid[1] - 1].totBall + 1)) : (trace("Increased")));
_global.row[old_cidrid[0] - 1].columns[old_cidrid[1] - 1].Bclr = "";
if (_global.row[new_cidrid[1] - 1].columns[new_cidrid[2] - 1].Bclr == "w") {
whiteBalls--;
((_global.row[new_cidrid[1] - 1].totBall > 0) ? ((_global.row[new_cidrid[1] - 1].totBall = _global.row[new_cidrid[1] - 1].totBall - 1)) : (trace("oh decreasing for white")));
_global.row[new_cidrid[1] - 1].columns[new_cidrid[2] - 1].ball._visible = 0;
} else if (_global.row[new_cidrid[1] - 1].columns[new_cidrid[2] - 1].Bclr == "b") {
blackBalls--;
((_global.row[new_cidrid[1] - 1].totBall > 0) ? ((_global.row[new_cidrid[1] - 1].totBall = _global.row[new_cidrid[1] - 1].totBall - 1)) : (trace("oh decreasing for black")));
_global.row[new_cidrid[1] - 1].columns[new_cidrid[2] - 1].ball._visible = 0;
}
_global.row[new_cidrid[1] - 1].columns[new_cidrid[2] - 1].Bclr = currclr;
_global.row[new_cidrid[1] - 1].columns[new_cidrid[2] - 1].ball = oldcellref;
currclr = ((currclr == "w") ? "b" : "w");
shuffleandenable();
}
function shuffleandenable() {
if (currclr == "w") {
currplayer = "Player 1 ";
_global.obj.__board._parent.player.text = currplayer + " is Playing...";
var i = 0;
while (i <= 24) {
_global.obj.__board["b" + i].btn_.enabled = 0;
_global.obj.__board["w" + i].btn_.enabled = 1;
i++;
}
} else if (currclr == "b") {
currplayer = "Player 2 ";
_global.obj.__board._parent.player.text = currplayer + " is Playing...";
var i = 0;
while (i <= 24) {
_global.obj.__board["w" + i].btn_.enabled = 0;
_global.obj.__board["b" + i].btn_.enabled = 1;
i++;
}
}
var i = 0;
while (i < 8) {
trace((("_global.row[i].totBall : in row " + (i + 1)) + " -- ") + _global.row[i].totBall);
i++;
}
checkWinner();
}
function tracktarget(drpt) {
var drpstrarr = drpt.split("");
if ((drpstrarr[0] == "w") || (drpstrarr[0] == "b")) {
var actuldrp = _global.obj.__board[drpt].cellno.split("");
return((("mc_base$" + actuldrp[0]) + "$") + actuldrp[1]);
}
return(drpt);
}
function RemoveHint() {
var i = 0;
while (i < Linesarr.length) {
Linesarr[i]._visible = 0;
removeMovieClip(Linesarr[i]);
i++;
}
}
function checkWinner() {
if ((blackBalls == 0) && (whiteBalls == 0)) {
_global.obj.__board._parent.player.text = "Draw !";
gameOver = true;
_root.gameOver_mc.gotoAndPlay(2);
} else if (blackBalls <= 0) {
_global.obj.__board._parent.player.text = "Player 1 is the winner";
gameOver = true;
} else if (whiteBalls <= 0) {
_global.obj.__board._parent.player.text = "Player 2 is the winner";
gameOver = true;
}
}
}
Symbol 32 Button
on (release) {
gotoAndStop ("start");
}
Symbol 35 Button
on (release) {
help_mc._visible = 1;
help_mc.gotoAndPlay(2);
}
Symbol 44 MovieClip Frame 9
stop();
Symbol 57 Button
on (release) {
this._visible = 0;
}
Symbol 60 MovieClip Frame 1
btn.useHandCursor = false;
stop();
Symbol 60 MovieClip Frame 10
stop();
Symbol 64 MovieClip Frame 1
stop();
Symbol 64 MovieClip Frame 5
stop();
Symbol 67 MovieClip Frame 1
stop();
Symbol 67 MovieClip Frame 5
stop();
Symbol 73 Button
on (release) {
gotoAndStop ("menu");
}
Symbol 76 Button
on (release) {
fscommand ("quit", true);
}
Symbol 77 Button
on (release) {
help_mc._visible = 1;
help_mc.gotoAndPlay(2);
}
Symbol 93 MovieClip Frame 1
stop();
Symbol 93 MovieClip Frame 12
stop();