Frame 15
totalBytes = this.getBytesTotal();
Frame 16
totalBytesLoaded = this.getBytesLoaded();
percent = (totalBytesLoaded / totalBytes) * 100;
if (percent >= 100) {
} else {
gotoAndPlay (15);
}
percent = int(percent) + "%";
ls = Math.round((totalBytesLoaded / (getTimer() / 1000)) / 10.24) / 100;
var speedload = (("@ " + ls) + "kbs");
Frame 18
function init() {
gHintTime = 2700;
gPoints = [];
gNumRows = 8;
gNumCols = 8;
gJewelWidth = 36;
gJewelHeight = 33;
gNumTypes = 7;
gTypesArray = new Array();
gTypesArray = [1, 2, 3, 4, 5, 6, 7];
NORMAL = 1;
SHRINKING = 2;
SLIDING = 3;
SWAPPING = 4;
UNSWAPPING = 5;
HINT = 6;
CHECKMORE = 7;
GAMEOVER = 8;
gDebug = false;
gDebug1 = false;
score = 0;
scorecheck = "0";
}
function setUp() {
_root.board_button._width = gNumCols * gJewelWidth;
_root.board_button._height = gNumRows * gJewelHeight;
_root.board_button._x = _root.jewel_MCA._x;
_root.board_button._y = _root.jewel_MCA._y;
_root.board_button.gotoAndStop("inactive");
gJewel = new Array();
do {
gJewelID = 1;
var i = 1;
while (gNumRows >= i) {
gJewel[i] = new Array();
var j = 1;
while (gNumCols >= j) {
var lName = ("jewel_" + gJewelID);
jewel_MCA.initJewel.duplicateMovieClip(lName, gJewelID);
gJewel[i][j] = gJewelID;
_root.jewel_MCA[lName].pRow = i;
_root.jewel_MCA[lName].pCol = j;
_root.jewel_MCA[lName].pID = gJewelID;
_root.jewel_MCA[lName]._x = (j - 0.5) * gJewelWidth;
_root.jewel_MCA[lName]._y = (i - 0.5) * gJewelHeight;
_root.jewel_MCA[lName].pFrameTimer = -1;
if (gDebug) {
var x = Math.ceil(j / 2);
var y = Math.ceil(i / 2);
if (odd(x + y)) {
var lType = 1;
} else {
var lType = 2;
}
} else if (gDebug1) {
var x = Math.ceil(j / 2);
var y = Math.ceil(i / 2);
var frac = (((x + y) / 3) - Math.floor((x + y) / 3));
var mod = (frac * 3);
if (mod == 0) {
var lType = 1;
} else if (mod == 1) {
var lType = 2;
} else if (mod == 2) {
var lType = 3;
}
} else {
var lType = Math.ceil(Math.random() * gNumTypes);
}
_root.jewel_MCA[lName].apple.gotoAndStop(lType);
var lMatch = true;
var k = 1;
while (2 >= k) {
var r = i;
var c = (j - k);
if (c < 1) {
lMatch = false;
break;
}
var lName = ("jewel_" + gJewel[r][c]);
var lJewel = _root.jewel_MCA[lName];
if (lJewel.apple._currentFrame != lType) {
lMatch = false;
break;
}
k++;
}
if (!lMatch) {
lMatch = true;
var k = 1;
while (2 >= k) {
var r = (i - k);
var c = j;
if (r < 1) {
lMatch = false;
break;
}
var lName = ("jewel_" + gJewel[r][c]);
var lJewel = _root.jewel_MCA[lName];
if (lJewel.apple._currentFrame != lType) {
lMatch = false;
break;
}
k++;
}
}
if (lMatch) {
var lChoice = gTypesArray.slice(0);
r = i;
c = j - 1;
if (0 < c) {
var lName = ("jewel_" + gJewel[r][c]);
var lJewel = _root.jewel_MCA[lName];
var lType = lJewel.apple._currentFrame;
var lIndex = getOne(lChoice, lType);
lChoice.splice(lIndex, 1);
}
r = i - 1;
c = j;
if (0 < r) {
var lName = ("jewel_" + gJewel[r][c]);
var lJewel = _root.jewel_MCA[lName];
var lType = lJewel.apple._currentFrame;
var lIndex = getOne(lChoice, lType);
if (lIndex != -1) {
lChoice.splice(lIndex, 1);
}
}
if (gDebug || (gDebug1)) {
var lIndex = 1;
} else {
var lIndex = Math.floor(Math.random() * lChoice.length);
}
var lName = ("jewel_" + gJewelID);
_root.jewel_MCA[lName].apple.gotoAndStop(lChoice[lIndex]);
}
gJewelID++;
j++;
}
i++;
}
var lHasSwaps = checkHasSwaps();
} while (0 >= lHasSwaps.length);
var i = gNumRows;
while (i >= 1) {
var j = 1;
while (gNumCols >= j) {
var lJewel = jewelAt(i, j);
if (i == gNumRows) {
lJewel._y = ((-0.5 * gJewelHeight) - (Math.random() * 50)) - 2;
} else {
var lPrev = jewelAt(i + 1, j);
lJewel._y = ((lPrev._y - gJewelHeight) - (Math.random() * 50)) - 2;
}
j++;
}
i--;
}
gPlayLandSound = 0;
gNumLandSoundsPlayed = 0;
gNumLanded = 0;
gLanded = new Array();
var j = 1;
while (gNumCols >= j) {
gLanded[j] = gNumRows + 1;
j++;
}
_root.points_MCA._x = _root.jewel_MCA._x;
_root.points_MCA._y = _root.jewel_MCA._y;
gSelected = 0;
gMode = SETUP;
gHasPoints = false;
placeOffstage(_root.game_over_explanation_MC);
placeOffstage(_root.bonusMC);
startGameTime = 0;
updateGameStats();
playSound("beginsound");
}
function setupVars() {
score = 0;
scorecheck = "0";
_root.game_stats.score = 0;
gMostMatchesPerSwap = 0;
gHighestScoringSwap = 0;
gLongestChain = 0;
nextBonus = 1000;
removeBonusTime = 0;
gGameBeginTime = getTimer();
gEndGameTime = getTimer() + _root.timetoend;
gGameTimer = getTimer();
gLastMatchTime = getTimer();
}
function frameLoop() {
if (gMode == NORMAL) {
var lTime = getTimer();
if ((gGameTimer + 5000) < lTime) {
updateScore(-1);
gGameTimer = lTime;
}
if ((gLastMatchTime + 30000) < lTime) {
showHint();
}
} else if (gMode == CHECKMORE) {
checkMoreMatches();
} else if ((gMode == SWAPPING) || (gMode == UNSWAPPING)) {
if (gSwapSteps < gSwapStep) {
if (gMode == SWAPPING) {
evaluateSwap();
} else {
gMode = NORMAL;
gSwapped = 0;
gSelected = 0;
}
} else {
gSelected._x = gSelected._x + gSelected.pSwapStep.x;
gSelected._y = gSelected._y + gSelected.pSwapStep.y;
gSwapped._x = gSwapped._x + gSwapped.pSwapStep.x;
gSwapped._y = gSwapped._y + gSwapped.pSwapStep.y;
}
gSwapStep++;
} else if (gMode == SHRINKING) {
gSize = gSize - 20;
if (0 < gSize) {
var i = 0;
while (i < gMatch.length) {
gMatch[i]._xscale = gSize;
gMatch[i]._yscale = gSize;
i++;
}
} else {
startSliding();
}
} else if (gMode == SLIDING) {
var i = 0;
while (i < gBlock.length) {
slide(gBlock[i]);
i++;
}
var i = 0;
while (i < gMatch.length) {
slide(gMatch[i]);
i++;
}
gSlideSpeed = gSlideSpeed + 2;
} else if (gMode == HINT) {
var i = 0;
while (i < gHint.length) {
var a = gHint[i]._alpha;
a = oscillate(a, 20, 100, 20);
if (a == 80) {
var lTime = getTimer();
if ((gHintTimer + gHintTime) < lTime) {
var i = 0;
while (i < gHint.length) {
gHint[i]._alpha = 100;
i++;
}
gMode = NORMAL;
}
}
if (gMode == HINT) {
gHint[i]._alpha = a;
}
i++;
}
} else if (gMode == SETUP) {
var lTime = getTimer();
if (gPlayLandSound == 0) {
this.playSound("pileup2");
gPlayLandSound = 1;
}
var j = 1;
while (gNumCols >= j) {
var lLowestMoving = (gLanded[j] - 1);
var i = lLowestMoving;
while (i >= 1) {
var lJewel = jewelAt(i, j);
var y = lJewel._y;
if (lJewel.pFrameTimer == -1) {
lJewel.pFrameTimer = lTime;
} else {
y = y + (((lTime - lJewel.pFrameTimer) * 20) / 33);
lJewel.pFrameTimer = lTime;
var lDestY = ((lJewel.pRow - 0.5) * gJewelHeight);
if (y >= lDestY) {
lJewel._y = lDestY;
gLanded[j] = i;
gNumLanded++;
currTime = getTimer();
if (3 < (currTime - gLastTickTime)) {
gLastTickTime = currTime();
playSound("tick");
}
} else {
lJewel._y = y;
}
}
i--;
}
j++;
}
if (gNumLanded >= (gNumCols * gNumRows)) {
gMode = NORMAL;
_root.board_button.gotoAndStop("active");
}
}
if (0 < gPoints.length) {
movePoints();
}
if ((startGameTime != 0) and (startGameTime < currTime)) {
placeOffstage(_root.game_over_explanation_MC);
setup();
}
if ((removeBonusTime != 0) and (removeBonusTime < currTime)) {
placeOffstage(_root.bonusMC);
removeBonusTime = 0;
}
checkGameTimer();
}
function place(vJewel) {
vJewel._x = (vJewel.pCol - 0.5) * gJewelWidth;
vJewel._y = (vJewel.pRow - 0.5) * gJewelHeight;
}
function jewelAt(r, c) {
var lName = ("jewel_" + gJewel[r][c]);
var lJewel = _root.jewel_MCA[lName];
return(lJewel);
}
function typeAt(r, c) {
var lJewel = jewelAt(r, c);
var lType = lJewel.apple._currentFrame;
return(lType);
}
function hasType(r, c, vType) {
if (!onBoard(r, c)) {
return(false);
}
var lType = typeAt(r, c);
if (lType == vType) {
return(true);
}
return(false);
}
function onBoard(r, c) {
if ((((r < 1) || (c < 1)) || (gNumRows < r)) || (gNumCols < c)) {
return(false);
}
return(true);
}
function startPoints(vValue, x, y) {
var lName = ("points_" + (gBonus + 1));
_root.points_MCA.initPoints.duplicateMovieClip(lName, gBonus + 1);
var lPointsMC = _root.points_MCA[lName];
lPointsMC._x = x;
lPointsMC._y = y;
lPointsMC.gotoAndStop(vValue / 10);
lPointsMC.pDestY = lPointsMC._y - 15;
lPointsMC.pFrameTimer = getTimer();
lPointsMC.pStartTimer = lPointsMC.pFrameTimer;
gPoints.push(lPointsMC);
updateScore(vValue);
gScoreThisSwap = gScoreThisSwap + vValue;
}
function updateScore(vChange) {
if (vChange < 0) {
_root.vChangeDisp = vChange;
} else {
_root.vChangeDisp = "+" add vChange;
}
var lScore = (score + vChange);
if (lScore < 0) {
vChange = -1 * score;
}
_root.game_stats.score = score + vChange;
score = score + vChange;
scorecheck = String(Number(scorecheck) + vChange);
if (nextBonus < score) {
bonusAmount = (((nextBonus - 1000) / 500) * 50) + 100;
if (250 < bonusAmount) {
bonusAmount = 250;
}
showBonus();
nextBonus = nextBonus + 500;
updateScore(bonusAmount);
}
}
function movePoints() {
var lTime = getTimer();
var i = (gPoints.length - 1);
while (i >= 0) {
var y = gPoints[i]._y;
y = y - ((lTime - gPoints[i].pFrameTimer) / 33);
gPoints[i]._y = y;
gPoints[i].pFrameTimer = lTime;
if ((gPoints[i].pStartTimer + 1000) < lTime) {
gPoints[i].removeMovieClip();
gPoints.splice(i, 1);
}
i--;
}
}
function clickedBoard(x, y) {
if ((gMode != NORMAL) && (gMode != HINT)) {
return(undefined);
}
this.playSound("click");
if (gMode == HINT) {
var i = 0;
while (i < gHint.length) {
gHint[i]._alpha = 100;
gMode = NORMAL;
i++;
}
}
if (gMode != NORMAL) {
return(undefined);
}
var c = Math.ceil((x - _root.jewel_MCA._x) / gJewelWidth);
var r = Math.ceil((y - _root.jewel_MCA._y) / gJewelHeight);
if (gSelected != 0) {
if (1 < (Math.abs(gSelected.pRow - r) + Math.abs(gSelected.pCol - c))) {
gSelected.apple.cursor.gotoAndStop("unselected");
gSelected = 0;
return(undefined);
}
}
var lName = ("jewel_" + gJewel[r][c]);
var lClicked = _root.jewel_MCA[lName];
if (gSelected == 0) {
gSelected = lClicked;
gSelected.apple.cursor.gotoAndStop("selected");
} else {
gSelected.apple.cursor.gotoAndStop("unselected");
if (lClicked == gSelected) {
gSelected = 0;
} else {
gSwapped = lClicked;
swap(gSelected, gSwapped, true);
}
}
}
function swap(vJewel1, vJewel2, vStarting) {
var r1 = vJewel1.pRow;
var c1 = vJewel1.pCol;
var r2 = vJewel2.pRow;
var c2 = vJewel2.pCol;
vJewel1.pRow = r2;
vJewel1.pCol = c2;
vJewel2.pRow = r1;
vJewel2.pCol = c1;
gJewel[r1][c1] = vJewel2.pID;
gJewel[r2][c2] = vJewel1.pID;
vJewel1.pSwapStep = {x:((c2 - c1) * gJewelWidth) / 5, y:((r2 - r1) * gJewelHeight) / 5};
vJewel2.pSwapStep = {x:((c1 - c2) * gJewelWidth) / 5, y:((r1 - r2) * gJewelHeight) / 5};
if (vStarting) {
gMode = SWAPPING;
gSwapStep = 1;
} else {
gMode = UNSWAPPING;
gSwapStep = 0;
}
gSwapSteps = 5;
}
function evaluateSwap() {
var rMin = gSelected.pRow;
var rMax = gSwapped.pRow;
if (rMax < rMin) {
var temp = rMin;
rMin = rMax;
rMax = temp;
}
var cMin = gSelected.pCol;
var cMax = gSwapped.pCol;
if (cMax < cMin) {
var temp = cMin;
cMin = cMax;
cMax = temp;
}
var lMatch = checkMatch(rMin, cMin, rMax, cMax);
gScoreThisSwap = 0;
gBonus = 0;
gPoints = new Array();
gMatch = new Array();
var i = 0;
while (i < lMatch.length) {
var lLength = lMatch[i].length;
gLongestChain = Math.max(gLongestChain, lLength);
var j = 0;
while (j < lLength) {
var lJewel = lMatch[i][j];
if (getOne(gMatch, lJewel) == -1) {
gMatch.push(lJewel);
}
j++;
}
var lPoints = (((lLength - 2) + gBonus) * 10);
if (odd(lLength)) {
var lWhich = Math.floor(lLength / 2);
var r = lMatch[i][lWhich].pRow;
var c = lMatch[i][lWhich].pCol;
} else {
var lWhich1 = ((lLength / 2) - 1);
var r1 = lMatch[i][lWhich1].pRow;
var c1 = lMatch[i][lWhich1].pCol;
var lWhich2 = (lLength / 2);
var r2 = lMatch[i][lWhich2].pRow;
var c2 = lMatch[i][lWhich2].pCol;
var r = ((r1 + r2) / 2);
var c = ((c1 + c2) / 2);
}
var x = ((c - 0.5) * gJewelWidth);
var y = ((r - 0.5) * gJewelHeight);
startPoints(lPoints, x, y);
gBonus++;
i++;
}
if (gMatch.length != 0) {
gSelected = 0;
gSwapped = 0;
startShrinking();
if (removeBonusTime == 0) {
this.playSound("match");
}
gLastMatchTime = getTimer();
} else {
swap(gSelected, gSwapped, false);
this.playSound("nomatch");
}
}
function startShrinking() {
gMode = SHRINKING;
gSize = 100;
}
function placeTemp(vJewel) {
vJewel._x = (vJewel.pCol - 0.5) * gJewelWidth;
vJewel._y = (-1 * (vJewel.pTempRow + 0.5)) * gJewelHeight;
}
function startSliding() {
gSlideSpeed = 1;
gMode = SLIDING;
gNewJewel = new Array();
var j = 1;
while (gNumCols >= j) {
gNewJewel[j] = new Array();
j++;
}
gBlockBottom = new Array();
var j = 1;
while (gNumCols >= j) {
gBlockBottom[j] = -1;
j++;
}
var i = 0;
while (i < gMatch.length) {
var c = gMatch[i].pCol;
gMatch[i]._xscale = 100;
gMatch[i]._yscale = 100;
gMatch[i].pTempRow = gNewJewel[c].length;
gNewJewel[c].push(gMatch[i]);
if (gDebug || (gDebug1)) {
var lType = 1;
} else {
var lType = Math.ceil(Math.random() * gNumTypes);
}
gMatch[i].apple.gotoAndStop(lType);
gMatch[i].pDoneSliding = false;
placeTemp(gMatch[i]);
gBlockBottom[c] = Math.max(gBlockBottom[c], gMatch[i].pRow - 1);
i++;
}
gBlock = new Array();
var j = 1;
while (gNumCols >= j) {
var i = 1;
while (gBlockBottom[j] >= i) {
var lJewel = jewelAt(i, j);
if (getOne(gMatch, lJewel) == -1) {
gBlock.push(lJewel);
lJewel.pDestRow = destRow(lJewel);
lJewel.pDoneSliding = false;
}
i++;
}
j++;
}
var i = 0;
while (i < gMatch.length) {
var c = gMatch[i].pCol;
gMatch[i].pDestRow = gNewJewel[c].length - gMatch[i].pTempRow;
i++;
}
gNumSliding = gMatch.length + gBlock.length;
gNumDoneSliding = 0;
}
function destRow(vJewel) {
var c = vJewel.pCol;
var r = vJewel.pRow;
var lNumRemovedBelow = 0;
var i = 0;
while (i < gNewJewel[c].length) {
if (r < gNewJewel[c][i].pRow) {
lNumRemovedBelow++;
}
i++;
}
var lDestRow = (r + lNumRemovedBelow);
return(lDestRow);
}
function slide(vJewel) {
if (vJewel.pDoneSliding) {
return(undefined);
}
var y = vJewel._y;
y = y + gSlideSpeed;
var lYDest = ((vJewel.pDestRow - 0.5) * gJewelHeight);
if (y >= lYDest) {
y = lYDest;
doneSliding(vJewel);
}
vJewel._y = y;
}
function doneSliding(vJewel) {
vJewel.pDoneSliding = true;
vJewel.pRow = vJewel.pDestRow;
gJewel[vJewel.pRow][vJewel.pCol] = vJewel.pID;
currTime = getTimer();
if (3 < (currTime - gLastTickTime)) {
gLastTickTime = getTimer();
playSound("tick");
}
gNumDoneSliding++;
if (gNumDoneSliding == gNumSliding) {
gMode = CHECKMORE;
}
}
function checkMoreMatches() {
var rMin = 1;
var cMin = gNumCols;
var rMax = 1;
var cMax = 1;
var i = 0;
while (i < gMatch.length) {
var r = gMatch[i].pRow;
var c = gMatch[i].pCol;
cMin = Math.min(cMin, c);
rMax = Math.max(rMax, r);
cMax = Math.max(cMax, c);
i++;
}
var i = 0;
while (i < gBlock.length) {
var r = gBlock[i].pRow;
var c = gBlock[i].pCol;
cMin = Math.min(cMin, c);
rMax = Math.max(rMax, r);
cMax = Math.max(cMax, c);
i++;
}
var lMatch = checkMatch(rMin, cMin, rMax, cMax);
gMatch = new Array();
var i = 0;
while (i < lMatch.length) {
var lLength = lMatch[i].length;
gLongestChain = Math.max(gLongestChain, lLength);
var j = 0;
while (j < lLength) {
var lJewel = lMatch[i][j];
if (getOne(gMatch, lJewel) == -1) {
gMatch.push(lJewel);
}
j++;
}
var lPoints = (((lLength - 2) + gBonus) * 10);
if (odd(lLength)) {
var lWhich = Math.floor(lLength / 2);
var r = lMatch[i][lWhich].pRow;
var c = lMatch[i][lWhich].pCol;
} else {
var lWhich1 = ((lLength / 2) - 1);
var r1 = lMatch[i][lWhich1].pRow;
var c1 = lMatch[i][lWhich1].pCol;
var lWhich2 = (lLength / 2);
var r2 = lMatch[i][lWhich2].pRow;
var c2 = lMatch[i][lWhich2].pCol;
var r = ((r1 + r2) / 2);
var c = ((c1 + c2) / 2);
}
var x = ((c - 0.5) * gJewelWidth);
var y = ((r - 0.5) * gJewelHeight);
startPoints(lPoints, x, y);
gBonus++;
i++;
}
if (0 < gMatch.length) {
if (removeBonusTime == 0) {
this.playSound("match");
}
startShrinking();
} else {
gHighestScoringSwap = Math.max(gHighestScoringSwap, gScoreThisSwap);
gMostMatchesPerSwap = Math.max(gMostMatchesPerSwap, gBonus);
updateGameStats();
gMode = NORMAL;
var lHasSwaps = checkHasSwaps();
if (lHasSwaps.length == 0) {
noMoreSwaps();
}
}
}
function updateGameStats() {
_root.game_stats.highest_scoring_turn = "Highest Scoring Turn: " + gHighestScoringSwap;
_root.game_stats.most_matches = "Most Matches Per Turn: " + gMostMatchesPerSwap;
_root.game_stats.longest_match = "Longest Match: " + gLongestChain;
}
function noMoreSwaps() {
startNewGame();
}
function quitGame() {
startNewGame();
}
function startNewGame() {
trace("Starting new game");
placeOnstage(_root.game_over_explanation_MC);
startGameTime = getTimer() + 5000;
this.playSound("gameover");
}
function showBonus() {
trace("Showing Bonus");
_root.bonusMC.bonusText = ("CONGRATULATIONS! YOU HAVE EARNED " + bonusAmount) + " BONUS POINTS!";
placeOnstage(_root.bonusMC);
removeBonusTime = getTimer() + 3000;
playSound("bonus");
}
function timeRanOut() {
_root.game_over_explanation_MC.game_over_explanation = "The game ended because\rtime ran out.";
terminateGame();
}
function terminateGame() {
this.playSound("gameover");
gotoAndStop (22);
gMode = GAMEOVER;
}
function continueGameOver() {
placeOffstage(_root.continue_button);
placeOffstage(_root.game_over_explanation_MC);
gotoAndStop (22);
}
function submitScore() {
extra = extra + "";
stats = stats + "";
}
function playAgain() {
gotoAndStop (20);
setUp();
}
function showHint() {
if (gMode != NORMAL) {
return(undefined);
}
updateScore(-20);
gLastMatchTime = getTimer();
this.playSound("hint");
gHintTimer = getTimer();
gHint = checkHasSwaps();
if (0 < gHint.length) {
var i = 0;
while (i < gHint.length) {
i++;
}
gMode = HINT;
}
}
function checkHasSwaps() {
var i = 1;
while (gNumRows >= i) {
var j = 1;
while (gNumCols >= j) {
var lType = typeAt(i, j);
if (hasType(i, j + 1, lType)) {
var r = i;
var c = (j - 1);
if (onBoard(r, c)) {
var lJewel1 = jewelAt(r, c);
if (hasType(r - 1, c, lType)) {
var lJewel2 = jewelAt(r - 1, c);
return([lJewel1, lJewel2]);
}
if (hasType(r, c - 1, lType)) {
var lJewel2 = jewelAt(r, c - 1);
return([lJewel1, lJewel2]);
}
if (hasType(r + 1, c, lType)) {
var lJewel2 = jewelAt(r + 1, c);
return([lJewel1, lJewel2]);
}
}
var r = i;
var c = (j + 2);
if (onBoard(r, c)) {
var lJewel1 = jewelAt(r, c);
if (hasType(r - 1, c, lType)) {
var lJewel2 = jewelAt(r - 1, c);
return([lJewel1, lJewel2]);
}
if (hasType(r, c + 1, lType)) {
var lJewel2 = jewelAt(r, c + 1);
return([lJewel1, lJewel2]);
}
if (hasType(r + 1, c, lType)) {
var lJewel2 = jewelAt(r + 1, c);
return([lJewel1, lJewel2]);
}
}
} else if (hasType(i, j + 2, lType)) {
var r = i;
var c = (j + 1);
var lJewel1 = jewelAt(r, c);
if (hasType(r - 1, c, lType)) {
var lJewel2 = jewelAt(r - 1, c);
return([lJewel1, lJewel2]);
}
if (hasType(r + 1, c, lType)) {
var lJewel2 = jewelAt(r + 1, c);
return([lJewel1, lJewel2]);
}
}
if (hasType(i + 1, j, lType)) {
var r = (i - 1);
var c = j;
if (onBoard(r, c)) {
var lJewel1 = jewelAt(r, c);
if (hasType(r, c - 1, lType)) {
var lJewel2 = jewelAt(r, c - 1);
return([lJewel1, lJewel2]);
}
if (hasType(r - 1, c, lType)) {
var lJewel2 = jewelAt(r - 1, c);
return([lJewel1, lJewel2]);
}
if (hasType(r, c + 1, lType)) {
var lJewel2 = jewelAt(r, c + 1);
return([lJewel1, lJewel2]);
}
}
var r = (i + 2);
var c = j;
if (onBoard(r, c)) {
var lJewel1 = jewelAt(r, c);
if (hasType(r, c - 1, lType)) {
var lJewel2 = jewelAt(r, c - 1);
return([lJewel1, lJewel2]);
}
if (hasType(r + 1, c, lType)) {
var lJewel2 = jewelAt(r + 1, c);
return([lJewel1, lJewel2]);
}
if (hasType(r, c + 1, lType)) {
var lJewel2 = jewelAt(r, c + 1);
return([lJewel1, lJewel2]);
}
}
} else if (hasType(i + 2, j, lType)) {
var r = (i + 1);
var c = j;
var lJewel1 = jewelAt(r, c);
if (hasType(r, c - 1, lType)) {
var lJewel2 = jewelAt(r, c - 1);
return([lJewel1, lJewel2]);
}
if (hasType(r, c + 1, lType)) {
var lJewel2 = jewelAt(r, c + 1);
return([lJewel1, lJewel2]);
}
}
j++;
}
i++;
}
return([]);
}
function checkMatch(vRowMin, vColMin, vRowMax, vColMax) {
var lHoriz = new Array();
var i = vRowMin;
while (vRowMax >= i) {
var j = vColMin;
for ( ; vColMax >= j ; j++) {
var lMatch = new Array();
var lType = typeAt(i, j);
var lJewel = jewelAt(i, j);
lMatch.push(lJewel);
var r = i;
var c = j;
if (j == vColMin) {
while (true) {
c--;
if (hasType(r, c, lType)) {
var lJewel = jewelAt(r, c);
lMatch.splice(0, 0, lJewel);
} else {
break;
}
}
} else {
var lAlready = false;
var k = 0;
while (k < lHoriz.length) {
if (getOne(lHoriz[k], lJewel) != -1) {
lAlready = true;
break;
}
k++;
}
if (lAlready) {
continue;
}
}
c = j;
while (true) {
c++;
if (hasType(r, c, lType)) {
var lJewel = jewelAt(r, c);
lMatch.push(lJewel);
} else {
break;
}
}
if (2 < lMatch.length) {
lHoriz.push(lMatch);
}
}
i++;
}
var lVert = new Array();
var i = vRowMin;
while (vRowMax >= i) {
var j = vColMin;
for ( ; vColMax >= j ; j++) {
var lMatch = new Array();
var lType = typeAt(i, j);
var lJewel = jewelAt(i, j);
lMatch.push(lJewel);
var r = i;
var c = j;
if (i == vRowMin) {
while (true) {
r--;
if (hasType(r, c, lType)) {
var lJewel = jewelAt(r, c);
lMatch.splice(0, 0, lJewel);
} else {
break;
}
}
} else {
var lAlready = false;
var k = 0;
while (k < lVert.length) {
if (getOne(lVert[k], lJewel) != -1) {
lAlready = true;
break;
}
k++;
}
if (lAlready) {
continue;
}
}
r = i;
while (true) {
r++;
if (hasType(r, c, lType)) {
var lJewel = jewelAt(r, c);
lMatch.push(lJewel);
} else {
break;
}
}
if (2 < lMatch.length) {
lVert.push(lMatch);
}
}
i++;
}
var lSet = lHoriz.concat(lVert);
return(lSet);
}
function getOne(array, x) {
var i = 0;
while (i < array.length) {
if (x == array[i]) {
return(i);
}
i++;
}
return(-1);
}
function placeOffstage(vObj) {
with (vObj) {
if (0 < _x) {
_x = _x - 1000;
}
}
}
function placeOnstage(vObj) {
with (vObj) {
if (_x < 0) {
_x = _x + 1000;
}
}
}
function odd(x) {
if ((x / 2) == Math.floor(x / 2)) {
return(false);
}
return(true);
}
function debug() {
if (gCanCheckMoreMatches) {
checkMoreMatches();
gCanCheckMoreMatches = false;
}
}
function oscillate(vValue, vMin, vMax, vInc) {
vValue = Math.floor(vValue + 0.5);
if (odd(vValue) || (vValue == 0)) {
var lDir = 1;
} else {
var lDir = -1;
}
vValue = vValue + (lDir * vInc);
if (vMin >= vValue) {
vValue = vMin;
if (!odd(vValue)) {
vValue++;
}
} else if (vValue >= vMax) {
vValue = vMax;
if (odd(vValue)) {
vValue--;
}
}
return(vValue);
}
function playSound(theSound) {
this.sounds1.goToAndPlay(theSound);
}
function checkGameTimer() {
if (gMode != GAMEOVER) {
currTime = getTimer();
if (gEndGameTime < currTime) {
setTimeLeft(0);
timeRanOut();
} else {
setTimeLeft((gEndGameTime - currTime) + 1000);
}
}
}
function setTimeLeft(timeLeft) {
minutes = int(timeLeft / 60000);
seconds = int(timeLeft / 1000) - (minutes * 60);
if (minutes < 1) {
minutes = "0";
}
if (seconds < 10) {
seconds = "0" + seconds;
}
gameTimeString = String((minutes add ":") add seconds);
gameTimeString = (String(minutes) + ":") + String(seconds);
}
if (_root.ptype == 1) {
_root.timetoend = 60000;
} else {
_root.timetoend = 300000 /* 0x0493E0 */;
}
Frame 20
init();
setUp();
setupVars();
stop();
Instance of Symbol 17 MovieClip in Frame 20
onClipEvent (enterFrame) {
_root.frameLoop();
}
Frame 22
play();
Symbol 13 Button
on (press) {
var x = _root._xmouse;
var y = _root._ymouse;
_root.clickedBoard(x, y);
}
Symbol 14 Button
on (press) {
var x = _root._xmouse;
var y = _root._ymouse;
_root.clickedBoard(x, y);
}
Symbol 11 MovieClip Frame 1
stop();
Symbol 21 MovieClip Frame 1
stop();
Symbol 19 MovieClip Frame 1
stop();
Symbol 29 MovieClip Frame 1
stop();
Symbol 59 MovieClip Frame 1
stop();
Symbol 59 MovieClip Frame 2
stop();
Symbol 52 MovieClip Frame 1
stop();
if (_root.logover == 1) {
logo_switch.gotoAndStop(1);
} else if (_root.logover == 2) {
logo_switch.gotoAndStop(2);
}
Symbol 70 MovieClip Frame 1
stop();
Symbol 70 MovieClip Frame 32
gotoAndStop (1);
Symbol 70 MovieClip Frame 97
gotoAndStop (1);
Symbol 70 MovieClip Frame 124
gotoAndStop (1);
Symbol 70 MovieClip Frame 174
gotoAndStop (1);
Symbol 70 MovieClip Frame 190
gotoAndStop (1);
Symbol 70 MovieClip Frame 302
gotoAndStop (1);
Symbol 70 MovieClip Frame 307
gotoAndStop (1);
Symbol 70 MovieClip Frame 417
gotoAndStop (1);
Symbol 70 MovieClip Frame 486
gotoAndStop (1);
Symbol 81 MovieClip Frame 1
score = _root.score;
gcode = _root.gcode;
getURL ("game.cfm", "_self", "POST");
Symbol 87 MovieClip Frame 1
var gname = "diamondmine";
var gscore = _root.score;
getURL ("index.php?act=Arcade&do=newscore", "_self", "POST");