Frame 1
function initSound() {
drawSound = new Sound();
drawSound.attachSound("drawSound");
boxSound = new Sound();
boxSound.attachSound("boxSound");
dropSound = new Sound();
dropSound.attachSound("dropSound");
youSound = new Sound();
youSound.attachSound("youSound");
foeSound = new Sound();
foeSound.attachSound("foeSound");
nextRoundSound = new Sound();
nextRoundSound.attachSound("nextRoundSound");
btnSound1 = new Sound();
btnSound1.attachSound("btn1");
btnSound2 = new Sound();
btnSound2.attachSound("btn2");
btnSound3 = new Sound();
btnSound3.attachSound("btn3");
bgSound = new Sound();
}
function playSound(key) {
if (!soundon) {
return(undefined);
}
switch (key) {
case "win" :
winSound.start();
break;
case "box" :
boxSound.start();
break;
case "drop" :
dropSound.start();
break;
case "youSound" :
youSound.start();
break;
case "foeSound" :
foeSound.start();
break;
case "nextRoundSound" :
nextRoundSound.start();
break;
case "startGameSound" :
startGameSound.start();
break;
case "btn1" :
btnSound1.start();
break;
case "btn2" :
btnSound2.start();
break;
case "btn3" :
btnSound3.start();
}
}
function playBGsound(key) {
if (!soundon) {
return(undefined);
}
bgSound.stop();
bgSound.attachSound(key);
bgSound.setVolume(40);
bgSound.start(0, 10000);
}
function init() {
initSound();
playBGsound("startGameBGsound");
instructionMC._visible = false;
startBTN.onRelease = function () {
_root.playSound("btn1");
gotoAndStop ("selectMode");
};
instructionMC.closeBtn.onRelease = function () {
_root.playSound("btn1");
instructionMC._visible = false;
};
instructionBtn.onRelease = function () {
_root.playSound("btn1");
instructionMC._visible = true;
};
}
stop();
var boxObj;
var computerIntervalID;
var turnCounter;
var playerSelected;
var playerTurn;
var computer = false;
var difficulty;
var roundLimit = 5;
var roundMax = 12;
var round = 0;
var score = 0;
var player1Card = 0;
var player2Card = 0;
var winIntervalID;
var playerLastInput;
var soundon = true;
var bgSoundObj;
init();
Frame 5
stop();
vsComputerBtn.onRelease = function () {
_root.playSound("btn1");
computer = true;
levelMc.gotoAndPlay(2);
};
vsPlayerBtn.onRelease = function () {
_root.playSound("btn1");
computer = false;
gotoAndStop ("selectPlayer");
};
Frame 11
function disableSelectionChip(bol) {
playerMC2.enabled = bol;
playerMC1.enabled = bol;
}
stop();
numberOfRoundMC._visible = false;
disableSelectionChip(true);
playerMC2.onRelease = function () {
_root.playSound("btn1");
playerSelected = 1;
disableSelectionChip(false);
numberOfRoundMC._visible = true;
};
playerMC2.onRollOver = function () {
chipMC.chipMC.gotoAndStop(1);
chipMC.gotoAndPlay("dropped");
};
playerMC1.onRelease = function () {
_root.playSound("btn1");
playerSelected = 2;
disableSelectionChip(false);
numberOfRoundMC._visible = true;
};
playerMC1.onRollOver = function () {
chipMC.chipMC.gotoAndStop(2);
chipMC.gotoAndPlay("dropped");
};
Frame 22
function setBoxContainer() {
for (var _local3 in boxContainerMC) {
boxContainerMC[_local3].onRelease = function () {
_root.playSound("btn2");
this.enabled = false;
attachChips("chip" + this._name, (this._x + (this._width / 2)) - 1, this._y + (this._height / 2));
setResult(this._name);
};
boxContainerMC[_local3].onRollOver = function () {
this.gotoAndPlay("rollOver");
playSound("box");
};
boxContainerMC[_local3].onRollOut = function () {
this.gotoAndPlay("rollOut");
};
}
}
function computerTurn() {
var _local1 = new Array();
var _local3;
for (var _local2 in boxObj) {
if (boxObj[_local2] > 2) {
_local1.push(_local2);
}
}
var _local4 = _local1[random(_local1.length)];
if (difficulty == 1) {
var _local5 = setNormalComputer(_local1);
_local3 = ((_local5 != null) ? (_local5) : (_local4));
} else if (playerLastInput != undefined) {
var _local5 = setHardComputer(_local1);
_local3 = ((_local5 != null) ? (_local5) : (_local4));
} else {
_local3 = _local4;
}
if (computerIntervalID != undefined) {
clearInterval(computerIntervalID);
}
computerIntervalID = setInterval(dropComputerChip, 600, _local3);
}
function setHardComputer(ar) {
var _local2 = playerSelected;
var _local1 = new Array();
var _local6 = null;
switch (playerLastInput) {
case "boxA1" :
_local1 = ["boxA2", "boxB2", "boxB1"];
if (boxObj.boxA2 == _local2) {
_local1 = ["boxA3"];
} else if (boxObj.boxA3 == _local2) {
_local1 = ["boxA2"];
} else if (boxObj.boxB1 == _local2) {
_local1 = ["boxC1"];
} else if (boxObj.boxC1 == _local2) {
_local1 = ["boxB1"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxC3"];
} else if (boxObj.boxC3 == _local2) {
_local1 = ["boxB2"];
}
break;
case "boxB1" :
_local1 = ["boxA1", "boxC1", "boxB2"];
if (boxObj.boxB2 == _local2) {
_local1 = ["boxB3"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxB3"];
} else if (boxObj.boxA1 == _local2) {
_local1 = ["boxC1"];
} else if (boxObj.boxC1 == _local2) {
_local1 = ["boxA1"];
}
break;
case "boxC1" :
_local1 = ["boxB1", "boxB2", "boxC2"];
if (boxObj.boxB1 == _local2) {
_local1 = ["boxA1"];
} else if (boxObj.boxA1 == _local2) {
_local1 = ["boxB1"];
} else if (boxObj.boxC2 == _local2) {
_local1 = ["boxC3"];
} else if (boxObj.boxC3 == _local2) {
_local1 = ["boxC2"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxA3"];
} else if (boxObj.boxA3 == _local2) {
_local1 = ["boxB2"];
}
break;
case "boxA2" :
_local1 = ["boxA1", "boxA3", "boxB2"];
if (boxObj.boxA1 == _local2) {
_local1 = ["boxA3"];
} else if (boxObj.boxA3 == _local2) {
_local1 = ["boxA1"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxC2"];
} else if (boxObj.boxC2 == _local2) {
_local1 = ["boxB2"];
}
break;
case "boxB2" :
_local1 = ["boxA1", "boxA2", "boxA3", "boxA2", "boxC2", "boxA3", "boxB3", "boxC3"];
if (boxObj.boxA1 == _local2) {
_local1 = ["boxC3"];
} else if (boxObj.boxC1 == _local2) {
_local1 = ["boxA3"];
} else if (boxObj.boxB1 == _local2) {
_local1 = ["boxB3"];
} else if (boxObj.boxB3 == _local2) {
_local1 = ["boxB1"];
} else if (boxObj.boxC3 == _local2) {
_local1 = ["boxA1"];
} else if (boxObj.boxC2 == _local2) {
_local1 = ["boxA2"];
} else if (boxObj.boxA2 == _local2) {
_local1 = ["boxC2"];
}
break;
case "boxC2" :
_local1 = ["boxC1", "boxB2", "boxC3"];
if (boxObj.boxC1 == _local2) {
_local1 = ["boxC2"];
} else if (boxObj.boxC2 == _local2) {
_local1 = ["boxC1"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxA2"];
} else if (boxObj.boxA2 == _local2) {
_local1 = ["boxB2"];
} else if (boxObj.boxC3 == _local2) {
_local1 = ["boxC1"];
} else if (boxObj.boxC1 == _local2) {
_local1 = ["boxC3"];
}
break;
case "boxA3" :
_local1 = ["boxA2", "boxB2", "boxB3"];
if (boxObj.boxA1 == _local2) {
_local1 = ["boxA2"];
} else if (boxObj.boxA2 == _local2) {
_local1 = ["boxA1"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxC1"];
} else if (boxObj.boxC1 == _local2) {
_local1 = ["boxB2"];
} else if (boxObj.boxB3 == _local2) {
_local1 = ["boxC3"];
} else if (boxObj.boxC3 == _local2) {
_local1 = ["boxB3"];
}
break;
case "boxB3" :
_local1 = ["boxA3", "boxB2", "boxC3"];
if (boxObj.boxA3 == _local2) {
_local1 = ["boxC3"];
} else if (boxObj.boxC3 == _local2) {
_local1 = ["boxA3"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxB1"];
} else if (boxObj.boxB1 == _local2) {
_local1 = ["boxB2"];
}
break;
case "boxC3" :
_local1 = ["boxC2", "boxB2", "boxB3"];
if (boxObj.boxA3 == _local2) {
_local1 = ["boxB3"];
} else if (boxObj.boxB3 == _local2) {
_local1 = ["boxA3"];
} else if (boxObj.boxB2 == _local2) {
_local1 = ["boxA1"];
} else if (boxObj.boxA1 == _local2) {
_local1 = ["boxB2"];
} else if (boxObj.boxC1 == _local2) {
_local1 = ["boxC2"];
} else {
if (boxObj.boxC2 != _local2) {
break;
}
_local1 = ["boxC1"];
}
}
var _local4 = new Array();
for (var _local7 in ar) {
for (var _local5 in _local1) {
if (_local1[_local5] == ar[_local7]) {
_local4.push(ar[_local7]);
}
}
}
_local6 = _local4[random(_local4.length)];
_local6 = ((_local6 != undefined) ? (_local6) : null);
return(_local6);
}
function setNormalComputer(ar) {
var _local1 = new Array();
var _local5 = null;
switch (playerLastInput) {
case "boxA1" :
_local1 = ["boxB1", "boxA2", "boxB2"];
break;
case "boxB1" :
_local1 = ["boxA1", "boxC1", "boxB2"];
break;
case "boxC1" :
_local1 = ["boxB1", "boxB2", "boxC2"];
break;
case "boxA2" :
_local1 = ["boxA1", "boxA3", "boxB2"];
break;
case "boxB2" :
_local1 = ["boxA1", "boxA2", "boxA3", "boxA2", "boxC2", "boxA3", "boxB3", "boxC3"];
break;
case "boxC2" :
_local1 = ["boxC1", "boxB2", "boxC3"];
break;
case "boxA3" :
_local1 = ["boxA2", "boxB2", "boxB3"];
break;
case "boxB3" :
_local1 = ["boxA3", "boxB2", "boxC3"];
break;
case "boxC3" :
_local1 = ["boxC2", "boxB2", "boxB3"];
}
var _local3 = new Array();
for (var _local6 in ar) {
for (var _local4 in _local1) {
if (_local1[_local4] == ar[_local6]) {
_local3.push(ar[_local6]);
}
}
}
_local5 = _local3[random(_local3.length)];
_local5 = ((_local5 != undefined) ? (_local5) : null);
return(_local5);
}
function dropComputerChip(comSelected) {
var _local1 = boxContainerMC[comSelected];
_local1.enabled = false;
attachChips("chip" + comSelected, (_local1._x + (_local1._width / 2)) - 1, _local1._y + (_local1._height / 2));
setResult(comSelected);
clearInterval(computerIntervalID);
}
function attachChips(mcName, xPos, yPos) {
var _local1 = chipContainerMC.attachMovie("chipsMC", mcName, chipContainerMC.getNextHighestDepth(), {_x:xPos, _y:yPos});
_local1.chipMC.gotoAndStop(playerTurn);
_local1.gotoAndPlay("dropped");
}
function setResult(mcName) {
if (playerTurn == playerSelected) {
playerLastInput = mcName;
setScore(10);
}
boxObj[mcName] = playerTurn;
if (isWin()) {
setWinMC(playerTurn);
} else {
setNextTurn();
trace(" setNextTurn -- ");
}
}
function setWinMC(n) {
removeMovieClip(winMC);
winMC = attachMovie("winMC", "winMC", this.getNextHighestDepth(), {_xscale:50, _yscale:50, _x:425, _y:225});
setEnabledBox(false);
if (n == 3) {
winMC.gotoAndStop(2);
cardMC.gotoAndPlay("draw");
playSound("drawSound");
} else {
winMC.gotoAndStop(1);
winMC.chipMC.gotoAndStop(n);
if (n == playerSelected) {
setScore(50);
player1Card++;
cardMC.gotoAndPlay("you");
playSound("youSound");
} else {
player2Card++;
cardMC.gotoAndPlay("foe");
playSound("foeSound");
}
}
if (winIntervalID != undefined) {
clearInterval(winIntervalID);
}
winIntervalID = setInterval(nextRound, 4000);
}
function isWin() {
var _local1 = false;
if (((boxObj.boxA1 == boxObj.boxB1) && (boxObj.boxB1 == boxObj.boxC1)) && (boxObj.boxA1 == boxObj.boxC1)) {
_local1 = true;
} else if (((boxObj.boxA2 == boxObj.boxB2) && (boxObj.boxB2 == boxObj.boxC2)) && (boxObj.boxA2 == boxObj.boxC2)) {
_local1 = true;
} else if (((boxObj.boxA3 == boxObj.boxB3) && (boxObj.boxB3 == boxObj.boxC3)) && (boxObj.boxA3 == boxObj.boxC3)) {
_local1 = true;
} else if (((boxObj.boxA1 == boxObj.boxA2) && (boxObj.boxA2 == boxObj.boxA3)) && (boxObj.boxA3 == boxObj.boxA1)) {
_local1 = true;
} else if (((boxObj.boxB1 == boxObj.boxB2) && (boxObj.boxB2 == boxObj.boxB3)) && (boxObj.boxB3 == boxObj.boxB1)) {
_local1 = true;
} else if (((boxObj.boxC1 == boxObj.boxC2) && (boxObj.boxC2 == boxObj.boxC3)) && (boxObj.boxC3 == boxObj.boxC1)) {
_local1 = true;
} else if (((boxObj.boxA1 == boxObj.boxB2) && (boxObj.boxB2 == boxObj.boxC3)) && (boxObj.boxA1 == boxObj.boxC3)) {
_local1 = true;
} else if (((boxObj.boxC1 == boxObj.boxB2) && (boxObj.boxB2 == boxObj.boxA3)) && (boxObj.boxA3 == boxObj.boxC1)) {
_local1 = true;
}
return(_local1);
}
function startGame() {
roundMC._visible = false;
playerTurn = 1;
if (playerSelected == 1) {
setEnabledBox(true);
} else if (computer) {
setEnabledBox(false);
computerTurn();
} else {
setEnabledBox(true);
setBoxContainer();
}
}
function setNextTurn() {
playerTurn = ((playerTurn == 1) ? 2 : 1);
trace((("next turn " + playerTurn) + " ") + computer);
trace("playerSelected " + playerSelected);
setPlayerTurnMC();
turnCounter++;
if (turnCounter > 9) {
setWinMC(3);
return(undefined);
}
if (computer && (playerTurn != playerSelected)) {
trace("computer turn");
setEnabledBox(false);
computerTurn();
} else {
trace("player Turn ");
setEnabledBox(true);
}
}
function init() {
boxObj = new Object();
clearInterval(winIntervalID);
if (chipContainerMC == undefined) {
chipContainerMC = createEmptyMovieClip("chipContainerMC", this.getNextHighestDepth());
}
winMC._visible = false;
setEnabledBox(false);
boxObj = {boxA1:3, boxB1:4, boxC1:5, boxA2:6, boxB2:7, boxC2:8, boxA3:9, boxB3:10, boxC3:11};
setBoxContainer();
turnCounter = 1;
}
function removeChips() {
for (var _local1 in chipContainerMC) {
removeMovieClip(chipContainerMC[_local1]);
}
}
function setEnabledBox(bol) {
if (!bol) {
for (var _local1 in boxContainerMC) {
boxContainerMC[_local1].enabled = false;
}
} else {
for (var _local1 in boxObj) {
if (boxObj[_local1] > 2) {
boxContainerMC[_local1].enabled = true;
}
}
}
}
function setPlayerTurnMC() {
var _local1 = ((playerTurn == 1) ? 2 : 1);
playerTurnMC.chipYouMC.gotoAndStop(((playerSelected == playerTurn) ? (playerTurn) : (_local1)));
playerTurnMC.chipYouMC._alpha = ((playerSelected == playerTurn) ? 100 : 20);
playerTurnMC.chipFoeMC.gotoAndStop(((playerSelected == playerTurn) ? (_local1) : (playerTurn)));
playerTurnMC.chipFoeMC._alpha = ((playerSelected != playerTurn) ? 100 : 20);
playerTurnMC.labelFoeMC.gotoAndStop((computer ? "computer" : "player2"));
playerTurnMC.youImg.num.text = player1Card;
playerTurnMC.foeImg.num.text = player2Card;
}
function nextRound() {
clearInterval(winIntervalID);
playSound("nextRound");
round++;
if (round > roundLimit) {
removeMovieClip(winMC);
removeChips();
gotoAndStop ("gameOver");
return(undefined);
}
init();
removeChips();
roundMC._visible = true;
roundMC.mc.gotoAndPlay("animPlay");
roundMC.mc.roundNum.gotoAndStop(round);
cardMC.gotoAndPlay("anim");
setPlayerTurnMC();
roundTxt.text = round;
}
function setScore(val) {
score = score + val;
scoreTxt.text = score;
}
function showTrace(msg) {
trace(msg);
}
var boxContainerMC;
var chipContainerMC;
var winMC;
initSound();
nextRound();
Frame 30
function createThumbs() {
thumbsHolder = createEmptyMovieClip("thumbsHolder", this.getNextHighestDepth());
thumbsHolder._x = 10;
thumbsHolder._y = 200;
var _local4 = 1;
var _local5 = 0;
i = 1;
while (i <= playerPhotos) {
var _local3 = thumbsHolder.attachMovie("imgThumbs", "imgThumbs" + i, thumbsHolder.getNextHighestDepth());
if (_local4 > 6) {
_local5++;
_local4 = 1;
}
_local3._y = (_local3._height + 5) * _local5;
_local3._x = (_local3._width + 5) * _local4;
_local3.num.text = i;
_local4++;
_local3.onRelease = function () {
_root.playSound("btn2");
_root.showImg(rndImage[Number(this.num.text)]);
trace("Img -- " + rndImage[Number(this.num.text)]);
};
i++;
}
}
function setRanNumbers(low, high, num) {
var _local2 = new Array();
var _local1 = 0;
while (_local1 < (high - low)) {
_local2.push((_local1 + 1) + low);
_local1++;
}
var _local4 = new Array();
while (num--) {
_local4.push(_local2.splice(Math.floor(Math.random() * _local2.length), 1));
}
return(_local4);
}
function showImg(num) {
imgHolderMC.gotoAndStop(num);
}
function removeThumbs() {
for (var _local1 in thumbsHolder) {
removeMovieClip(thumbsHolder[_local1]);
}
}
stop();
var thumbsHolder;
var rndImage = new Array();
rndImage = setRanNumbers(1, roundMax, roundMax);
restartBtn.onRelease = function () {
removeThumbs();
_root.playSound("btn1");
gotoAndStop (1);
};
scoreTxt.text = score;
photoTxt.text = player1Card;
playerPhotos = player1Card;
createThumbs();
Symbol 18 MovieClip Frame 1
stop();
Symbol 20 MovieClip [winMC] Frame 1
stop();
Symbol 27 MovieClip [chipsMC] Frame 1
stop();
Symbol 27 MovieClip [chipsMC] Frame 10
play();
Symbol 27 MovieClip [chipsMC] Frame 20
stop();
Symbol 89 MovieClip Frame 1
stop();
Symbol 89 MovieClip Frame 2
play();
Symbol 89 MovieClip Frame 10
stop();
hardBtn.onRelease = function () {
_root.playSound("btn1");
_parent.difficulty = 2;
_parent.gotoAndStop("selectPlayer");
};
easyBtn.onRelease = function () {
_root.playSound("btn1");
_parent.difficulty = 1;
_parent.gotoAndStop("selectPlayer");
};
Symbol 117 MovieClip Frame 1
var roundLimit = _parent.roundLimit;
var roundMax = _parent.roundMax;
roundNumTxt.text = roundLimit;
downBtn.onRelease = function () {
_root.playSound("btn2");
var _local2 = roundNumTxt.text;
_local2 = (((_local2 <= roundMax) && (_local2 > 1)) ? (_local2 - 1) : 1);
roundNumTxt.text = _local2;
};
upBtn.onRelease = function () {
_root.playSound("btn2");
var _local2 = roundNumTxt.text;
_local2 = (((_local2 >= 1) && (_local2 < roundMax)) ? (Number(_local2) + 1) : (roundMax));
roundNumTxt.text = _local2;
};
startGameBtn.onRelease = function () {
_root.playSound("btn1");
_parent.roundLimit = roundNumTxt.text;
_parent.gotoAndStop("game");
};
Symbol 126 MovieClip Frame 1
stop();
Symbol 126 MovieClip Frame 15
stop();
Symbol 126 MovieClip Frame 26
gotoAndStop ("hold");
Symbol 141 MovieClip Frame 1
stop();
Symbol 146 MovieClip Frame 1
play();
Symbol 146 MovieClip Frame 70
stop();
_root.startGame();
Symbol 152 MovieClip Frame 1
stop();
Symbol 157 MovieClip Frame 1
play();
Symbol 157 MovieClip Frame 8
stop();
Symbol 157 MovieClip Frame 24
stop();
_root.playerTurnMC.youTxt.text = _root.player1Card;
Symbol 157 MovieClip Frame 39
stop();
_root.playerTurnMC.foeTxt.text = _root.player2Card;
Symbol 157 MovieClip Frame 53
stop();
Symbol 189 MovieClip Frame 1
stop();