Frame 2
MochiAd.showPreGameAd({id:"5465c29ca77aa829", res:"530x390"});
Frame 4
_root.bg = new Sound();
_root.bg.attachSound("bg");
_root.bg.setVolume(80);
_root.bg.start(0, 9999);
stop();
Instance of Symbol 119 MovieClip in Frame 4
onClipEvent (load) {
this.gotoAndStop(1);
}
Frame 5
points_text = "0";
var points = 0;
_root.numoftype = 4;
_root.notBusy = true;
_root.lvl = Number(1);
_root.timeGiven = Number(200);
_root.addOnTime = Number(200);
_root.txt1 = Number(0);
_root.txt2 = Number(0);
_root.txt3 = Number(0);
_root.txt4 = Number(0);
_root.txt5 = Number(0);
_root.txt6 = Number(0);
_root.txt7 = Number(0);
_root.txt8 = Number(0);
_root.txt9 = Number(0);
_root.max1 = Number(25);
_root.max2 = Number(25);
_root.max3 = Number(25);
_root.max4 = Number(25);
_root.max5 = Number(25);
_root.max6 = Number(25);
_root.max7 = Number(25);
_root.max8 = Number(25);
_root.max9 = Number(25);
clear1.textColor = 6684672 /* 0x660000 */;
clear2.textColor = 6684672 /* 0x660000 */;
clear3.textColor = 6684672 /* 0x660000 */;
clear4.textColor = 6684672 /* 0x660000 */;
left1.textColor = 6684672 /* 0x660000 */;
left2.textColor = 6684672 /* 0x660000 */;
left3.textColor = 6684672 /* 0x660000 */;
left4.textColor = 6684672 /* 0x660000 */;
_root.order1._alpha = 100;
_root.order2._alpha = 100;
_root.order3._alpha = 100;
_root.order4._alpha = 100;
_root.order5._alpha = 10;
_root.order6._alpha = 10;
_root.order7._alpha = 10;
_root.order8._alpha = 10;
_root.order9._alpha = 10;
_root.squish = new Sound();
_root.squish.attachSound("squish");
_root.squish.setVolume(100);
_root.checkAvailable = false;
Instance of Symbol 122 MovieClip in Frame 5
onClipEvent (load) {
this.gotoAndStop(1);
}
Instance of Symbol 151 MovieClip "timer_mc" in Frame 5
onClipEvent (load) {
_root.currentTime = _root.timeGiven;
timer = _root.currentTime;
_parent.flag = 0;
}
onClipEvent (enterFrame) {
if (_parent.flag == 1) {
_parent.flag = 0;
_parent.move_txt.textColor = 0;
_root.currentTime = _root.timeGiven;
}
if (_root.currentTime < 0) {
_root.gotoAndStop("lose");
}
if (_root.currentTime > 0) {
_root.currentTime = _root.currentTime - 0.05;
timer = Math.ceil(_root.currentTime);
if (_root.currentTime < 100) {
this.my_txt.textColor = 16737792 /* 0xFF6600 */;
}
if (_root.currentTime < 50) {
this.my_txt.textColor = 16711680 /* 0xFF0000 */;
}
}
}
Frame 6
if (_root.lvl == 2) {
clear1.textColor = 6684672 /* 0x660000 */;
clear2.textColor = 6684672 /* 0x660000 */;
clear3.textColor = 6684672 /* 0x660000 */;
clear4.textColor = 6684672 /* 0x660000 */;
clear5.textColor = 6684672 /* 0x660000 */;
left1.textColor = 6684672 /* 0x660000 */;
left2.textColor = 6684672 /* 0x660000 */;
left3.textColor = 6684672 /* 0x660000 */;
left4.textColor = 6684672 /* 0x660000 */;
left5.textColor = 6684672 /* 0x660000 */;
} else if (_root.lvl == 3) {
clear1.textColor = 6684672 /* 0x660000 */;
clear2.textColor = 6684672 /* 0x660000 */;
clear3.textColor = 6684672 /* 0x660000 */;
clear4.textColor = 6684672 /* 0x660000 */;
clear5.textColor = 6684672 /* 0x660000 */;
clear6.textColor = 6684672 /* 0x660000 */;
left1.textColor = 6684672 /* 0x660000 */;
left2.textColor = 6684672 /* 0x660000 */;
left3.textColor = 6684672 /* 0x660000 */;
left4.textColor = 6684672 /* 0x660000 */;
left5.textColor = 6684672 /* 0x660000 */;
left6.textColor = 6684672 /* 0x660000 */;
} else if (_root.lvl == 4) {
clear1.textColor = 6684672 /* 0x660000 */;
clear2.textColor = 6684672 /* 0x660000 */;
clear3.textColor = 6684672 /* 0x660000 */;
clear4.textColor = 6684672 /* 0x660000 */;
clear5.textColor = 6684672 /* 0x660000 */;
clear6.textColor = 6684672 /* 0x660000 */;
clear7.textColor = 6684672 /* 0x660000 */;
left1.textColor = 6684672 /* 0x660000 */;
left2.textColor = 6684672 /* 0x660000 */;
left3.textColor = 6684672 /* 0x660000 */;
left4.textColor = 6684672 /* 0x660000 */;
left5.textColor = 6684672 /* 0x660000 */;
left6.textColor = 6684672 /* 0x660000 */;
left7.textColor = 6684672 /* 0x660000 */;
} else if (_root.lvl == 5) {
clear1.textColor = 6684672 /* 0x660000 */;
clear2.textColor = 6684672 /* 0x660000 */;
clear3.textColor = 6684672 /* 0x660000 */;
clear4.textColor = 6684672 /* 0x660000 */;
clear5.textColor = 6684672 /* 0x660000 */;
clear6.textColor = 6684672 /* 0x660000 */;
clear7.textColor = 6684672 /* 0x660000 */;
clear8.textColor = 6684672 /* 0x660000 */;
left1.textColor = 6684672 /* 0x660000 */;
left2.textColor = 6684672 /* 0x660000 */;
left3.textColor = 6684672 /* 0x660000 */;
left4.textColor = 6684672 /* 0x660000 */;
left5.textColor = 6684672 /* 0x660000 */;
left6.textColor = 6684672 /* 0x660000 */;
left7.textColor = 6684672 /* 0x660000 */;
left8.textColor = 6684672 /* 0x660000 */;
} else if (_root.lvl == 6) {
clear1.textColor = 6684672 /* 0x660000 */;
clear2.textColor = 6684672 /* 0x660000 */;
clear3.textColor = 6684672 /* 0x660000 */;
clear4.textColor = 6684672 /* 0x660000 */;
clear5.textColor = 6684672 /* 0x660000 */;
clear6.textColor = 6684672 /* 0x660000 */;
clear7.textColor = 6684672 /* 0x660000 */;
clear8.textColor = 6684672 /* 0x660000 */;
clear9.textColor = 6684672 /* 0x660000 */;
left1.textColor = 6684672 /* 0x660000 */;
left2.textColor = 6684672 /* 0x660000 */;
left3.textColor = 6684672 /* 0x660000 */;
left4.textColor = 6684672 /* 0x660000 */;
left5.textColor = 6684672 /* 0x660000 */;
left6.textColor = 6684672 /* 0x660000 */;
left7.textColor = 6684672 /* 0x660000 */;
left8.textColor = 6684672 /* 0x660000 */;
left9.textColor = 6684672 /* 0x660000 */;
}
cell._visible = false;
var special = 0;
_root.comboflag = 1;
game = {};
game.board = _root.gameBoard;
game.board.game = game;
game.width = 8;
game.height = 8;
game.middle = Math.ceil(game.width / 2);
game.pixelwidth = 350;
game.pixelheight = 350;
game.xspacing = game.pixelwidth / game.width;
game.yspacing = game.pixelheight / game.height;
game.types = _root.numoftype;
game.depth = 100;
game.speed = 15;
game.selected = [];
game.selectItem = function (xm, ym) {
var _local1 = this;
var x = Math.ceil(xm / _local1.xspacing);
var _local3 = Math.ceil(ym / _local1.yspacing);
var cellClicked = ((("cell" + x) + "_") + _local3);
var _local2 = _local1[cellClicked];
if (!_local1.locked) {
if ((_local1.selected[0].x == x) && (_local1.selected[0].y == _local3)) {
_local1.selected[0].clip.select._visible = false;
_local1.selected = [];
} else {
_local2.clip.select._visible = true;
_local1.selected.push(_local2);
if (_local1.selected.length == 2) {
_local1.locked = true;
_local1.swapPlaces();
}
}
}
};
game.doneSlidingBack = function () {
var _local1 = this;
_local1.slid++;
if (_local1.slid == 2) {
_local1.locked = false;
}
};
game.addNewItems = function () {
var _local1 = this;
delete _local1.matched;
_local1.totalMoving = 0;
_local1.totalDoneMoving = 0;
var tempFunction = function () {
var _local1 = this;
if (!_local1.game.pause) {
_local1._x = _local1._x + _local1.speed;
_local1.x = (_local1.me.x - 0.5) * _local1.game.xspacing;
if (Math.abs(_local1._x - _local1.x) <= Math.abs(_local1.speed)) {
_local1._x = _local1.x;
_local1.game.doneMoving();
_local1.onEnterFrame = null;
}
}
};
if (_local1.left.length > 0) {
_local1.left.sortOn("x");
var _local2 = [];
var i = 0;
while (i < _local1.left.length) {
var keepGoing = true;
var j = 0;
while (keepGoing) {
if ((_local1.left[i].y == _local2[j][0].y) || (_local2[j] == undefined)) {
if (_local2[j][0] == undefined) {
_local2[j] = [];
}
_local1.totalmoving++;
_local2[j].push(_local1.left[i]);
var keepGoing = false;
}
j++;
}
i++;
}
var i = 0;
while (i < _local2.length) {
var xshift = 1;
var stayHere = true;
var rowTotal = _local2[i].length;
var tempOb = {};
while ((_local2[i].length > 0) && (stayHere)) {
var ob = _local2[i].pop();
var nextHole = _local2[i][_local2[i].length - xshift];
var beginX = (ob.x - 1);
var x = beginX;
var y = ob.y;
var keepGoing = true;
while (keepGoing) {
var tempName = ((("cell" + x) + "_") + y);
if (_local1[tempName].name != nextHole.name) {
var _local3 = ob.name;
delete _local1[_local3];
_local1[_local3] = {};
newCell = _local1[_local3];
newCell.x = x + xshift;
newCell.y = y;
newCell.name = _local3;
newCell.clip = _local1[tempName].clip;
newCell.type = _local1[tempName].type;
newCell.clip.onEnterFrame = tempFunction;
newCell.clip.speed = _local1.speed;
newCell.clip.game = _local1;
newCell.clip.me = newCell;
newCell.clip.x = (newCell.x - 0.5) * _local1.xspacing;
newCell.clip.y = (newCell.y - 0.5) * _local1.yspacing;
_local2[i].unshift(_local1[tempname]);
if (!tempOb[_local3].moving) {
tempOb[_local3].moving = true;
}
var xshift = 1;
var keepGoing = false;
} else if (_local1[tempName].name == nextHole.name) {
if (x > 1) {
x--;
xshift++;
var nextHole = _local2[i][_local2[i].length - xshift];
} else {
var numToAdd = rowTotal;
var n = 1;
while (n <= numToAdd) {
var stayHere = false;
var keepGoing = false;
var type = (random(_local1.types) + 1);
var x = n;
var name = ((("cell" + x) + "_") + y);
_local1[name] = {x:x, y:y, name:name, type:type};
_local1.addNewLeftClip(_local1[name], numToAdd);
_local1[name].clip.onEnterFrame = tempFunction;
_local1[name].clip.gotoAndStop(type);
n++;
}
}
}
}
}
i++;
}
}
if (_local1.right.length > 0) {
_local1.right.sortOn("x");
var _local2 = [];
var i = 0;
while (i < _local1.right.length) {
var keepGoing = true;
var j = 0;
while (keepGoing) {
if ((_local1.right[i].y == _local2[j][0].y) || (_local2[j] == undefined)) {
if (_local2[j][0] == undefined) {
_local2[j] = [];
}
_local2[j].push(_local1.right[i]);
_local1.totalmoving++;
var keepGoing = false;
}
j++;
}
i++;
}
now = getTimer();
var i = 0;
while (i < _local2.length) {
if ((getTimer() - now) > 2000) {
break;
}
var xshift = 1;
var stayHere = true;
var rowTotal = _local2[i].length;
var tempOb = {};
while ((_local2[i].length > 0) && (stayHere)) {
if ((getTimer() - now) > 2000) {
break;
}
var ob = _local2[i].shift();
var nextHole = _local2[i][xshift - 1];
var beginX = (ob.x + 1);
var x = beginX;
var y = ob.y;
var keepGoing = true;
while (keepGoing) {
if ((getTimer() - now) > 2000) {
break;
}
var tempName = ((("cell" + x) + "_") + y);
if (_local1[tempName].name != nextHole.name) {
var _local3 = ob.name;
delete _local1[_local3];
_local1[_local3] = {};
newCell = _local1[_local3];
newCell.x = x - xshift;
newCell.y = y;
newCell.name = _local3;
newCell.clip = _local1[tempName].clip;
newCell.type = _local1[tempName].type;
newCell.clip.onEnterFrame = tempFunction;
newCell.clip.speed = -_local1.speed;
newCell.clip.game = _local1;
newCell.clip.me = newCell;
newCell.clip.x = (newCell.x - 0.5) * _local1.xspacing;
newCell.clip.y = (newCell.y - 0.5) * _local1.yspacing;
_local2[i].push(_local1[tempname]);
if (!tempOb[_local3].moving) {
tempOb[_local3].moving = true;
}
var xshift = 1;
var keepGoing = false;
} else if (_local1[tempName].name == nextHole.name) {
if (x < _local1.width) {
x++;
xshift++;
var nextHole = _local2[i][xshift - 1];
} else {
var numToAdd = rowTotal;
var n = 1;
while (n <= numToAdd) {
var stayHere = false;
var keepGoing = false;
var type = (random(_local1.types) + 1);
var x = ((_local1.width - n) + 1);
var name = ((("cell" + x) + "_") + y);
_local1[name] = {x:x, y:y, name:name, type:type};
_local1.addNewRightClip(_local1[name], (rowTotal - n) + 0.5);
_local1[name].clip.onEnterFrame = tempFunction;
_local1[name].clip.gotoAndStop(type);
n++;
}
}
}
}
}
i++;
}
}
delete _local1.right;
delete _local1.left;
};
game.doneMoving = function () {
var _local1 = this;
_local1.totalDoneMoving++;
if (_local1.totalDoneMoving == _local1.totalMoving) {
var _local2 = _local1.checkForMatches();
if (_local2) {
_local1.playSquish();
_local1.removeItems();
_root.comboflag++;
} else {
_local1.selected = [];
_local1.locked = false;
_local1.displayPatch();
_local1.areThereMatches();
}
}
};
game.displayPatch = function () {
var _local3 = this;
var i = 1;
while (i <= _local3.width) {
var _local2 = 1;
while (_local2 <= _local3.height) {
var name = ((("cell" + i) + "_") + _local2);
var _local1 = _local3[name];
_local1.clip._x = (_local1.x - 0.5) * _local3.xspacing;
_local1.clip._y = (_local1.y - 0.5) * _local3.yspacing;
_local1.clip.onEnterFrame = null;
_local2++;
}
i++;
}
};
game.addNewRightClip = function (who, num) {
var _local1 = who;
var _local2 = this;
var newDepth = (++_local2.depth);
var _local3 = "donut" + newDepth;
_local2.board.attachMovie("donut", _local3, newDepth);
var tempx = ((_local1.x - 0.5) * _local2.xspacing);
var tempy = ((_local1.y - 0.5) * _local2.yspacing);
_local1.clip = _local2.board[_local3];
var a = (_local2.width + num);
var placex = (a * _local2.xspacing);
_local1.clip.me = _local1;
_local1.clip.dir = "right";
_local1.clip.x = tempx;
_local1.clip.y = tempy;
_local1.clip._x = placex;
_local1.clip._y = tempy;
_local1.clip.speed = -_local2.speed;
_local1.clip.game = _local2;
_local1.clip.gotoAndStop(_local1.type);
};
game.addNewLeftClip = function (who, num) {
var _local1 = who;
var _local2 = this;
var newDepth = (++_local2.depth);
var _local3 = "donut" + newDepth;
_local2.board.attachMovie("donut", _local3, newDepth);
var tempx = ((_local1.x - 0.5) * _local2.xspacing);
var placex = ((((num + 1) - _local1.x) - 0.5) * _local2.xspacing);
var tempy = ((_local1.y - 0.5) * _local2.yspacing);
_local1.clip = _local2.board[_local3];
_local1.clip.me = _local1;
_local1.clip.dir = "left";
_local1.clip.x = tempx;
_local1.clip.y = tempy;
_local1.clip._x = -placex;
_local1.clip._y = tempy;
_local1.clip.speed = _local2.speed;
_local1.clip.game = _local2;
_local1.clip.gotoAndStop(_local1.type);
};
game.premove = function () {
var _local1 = this;
_local1.left = [];
_local1.right = [];
var _local2 = 0;
while (_local2 < _local1.matched.length) {
if (_local1.matched[_local2].x <= _local1.middle) {
_local1.left.push(_local1.matched[_local2]);
} else {
_local1.right.push(_local1.matched[_local2]);
}
_local2++;
}
_local1.addNewItems();
};
game.removed = function (who) {
var _local1 = _root;
var _local2 = this;
who.removeMovieClip();
points = points + Number(_local1.comboflag * 10);
if (comboflag == 1) {
special = special + ((_local1.comboflag / _local1.comboflag) / 3);
}
_local2.removedSoFar++;
if (_local2.removedSoFar == _local2.itemsToRemove) {
_local2.premove();
points_text = points;
}
if (_local1.comboflag == 3) {
_local1.extra.gotoAndPlay("great");
} else if (_local1.comboflag == 5) {
_local1.extra.gotoAndPlay("excellent");
}
};
game.removeItems = function () {
var type:Number = 0;
this.itemsToRemove = this.matched.length;
this.removedSoFar = 0;
var i = 0;
while (i < this.matched.length) {
this.matched[i].clip.donut.game = this;
this.matched[i].clip.donut.play();
type = this.matched[i].clip._currentframe;
if (Number(_root["txt" + type]) < Number(Number(_root["max" + type]) - Number(1))) {
_root["txt" + type] = Number(_root["txt" + type]) + Number(1);
eval ("clear" + type).textColor = 6684672 /* 0x660000 */;
} else {
_root["txt" + type] = Number(_root["max" + type]);
_root["tick" + type].play();
eval ("clear" + type).textColor = 16750899 /* 0xFF9933 */;
eval ("left" + type).textColor = 16750899 /* 0xFF9933 */;
this.checkStatus();
}
i++;
}
};
game.checkStatus = function () {
var _local1 = _root;
if (_local1.lvl == 1) {
if ((((_local1.txt1 == Number(_local1.max1)) && (_local1.txt2 == Number(_local1.max2))) && (_local1.txt3 == Number(_local1.max3))) && (_local1.txt4 == Number(_local1.max4))) {
_local1.timeGiven = Number(_local1.addOnTime) + Math.ceil(_local1.currentTime);
_local1.gotoAndStop("nextlvl");
}
} else if (_local1.lvl == 2) {
if (((((_local1.txt1 == Number(_local1.max1)) && (_local1.txt2 == Number(_local1.max2))) && (_local1.txt3 == Number(_local1.max3))) && (_local1.txt4 == Number(_local1.max4))) && (_local1.txt5 == Number(_local1.max5))) {
_local1.timeGiven = Number(_local1.addOnTime) + Math.ceil(_local1.currentTime);
_local1.gotoAndStop("nextlvl");
}
} else if (_local1.lvl == 3) {
if ((((((_local1.txt1 == Number(_local1.max1)) && (_local1.txt2 == Number(_local1.max2))) && (_local1.txt3 == Number(_local1.max3))) && (_local1.txt4 == Number(_local1.max4))) && (_local1.txt5 == Number(_local1.max5))) && (_local1.txt6 == Number(_local1.max6))) {
_local1.timeGiven = Number(_local1.addOnTime) + Math.ceil(_local1.currentTime);
_local1.gotoAndStop("nextlvl");
}
} else if (_local1.lvl == 4) {
if (((((((_local1.txt1 == Number(_local1.max1)) && (_local1.txt2 == Number(_local1.max2))) && (_local1.txt3 == Number(_local1.max3))) && (_local1.txt4 == Number(_local1.max4))) && (_local1.txt5 == Number(_local1.max5))) && (_local1.txt6 == Number(_local1.max6))) && (_local1.txt7 == Number(_local1.max7))) {
_local1.timeGiven = Number(_local1.addOnTime) + Math.ceil(_local1.currentTime);
_local1.gotoAndStop("nextlvl");
}
} else if (_local1.lvl == 5) {
if ((((((((_local1.txt1 == Number(_local1.max1)) && (_local1.txt2 == Number(_local1.max2))) && (_local1.txt3 == Number(_local1.max3))) && (_local1.txt4 == Number(_local1.max4))) && (_local1.txt5 == Number(_local1.max5))) && (_local1.txt6 == Number(_local1.max6))) && (_local1.txt7 == Number(_local1.max7))) && (_local1.txt8 == Number(_local1.max8))) {
_local1.timeGiven = Number(_local1.addOnTime) + Math.ceil(_local1.currentTime);
_local1.gotoAndStop("nextlvl");
}
} else if (_local1.lvl == 6) {
if (((((((((_local1.txt1 == Number(_local1.max1)) && (_local1.txt2 == Number(_local1.max2))) && (_local1.txt3 == Number(_local1.max3))) && (_local1.txt4 == Number(_local1.max4))) && (_local1.txt5 == Number(_local1.max5))) && (_local1.txt6 == Number(_local1.max6))) && (_local1.txt7 == Number(_local1.max7))) && (_local1.txt8 == Number(_local1.max8))) && (_local1.txt9 == Number(_local1.max9))) {
_local1.timeGiven = Number(_local1.addOnTime) + Math.ceil(_local1.currentTime);
_local1.gotoAndStop("nextlvl");
}
}
};
game.playSquish = function () {
_root.squish.start();
};
game.doneSliding = function () {
var _local1 = this;
_local1.slid++;
if (_local1.slid == 2) {
var _local2 = _local1.verifySelections();
if (_local2) {
_local1.playSquish();
_local1.removeItems();
_root.comboflag = 1;
} else {
_local1.swapBack();
_local1.selected = [];
}
}
};
game.swapBack = function () {
var _local1 = this;
_local1.slid = 0;
var cell1 = _local1.selected[0];
var _local3 = _local1.selected[1];
var _local2 = function () {
var _local1 = this;
_local1.xmov = (_local1.homex - _local1._x) * _local1.k;
_local1.ymov = (_local1.homey - _local1._y) * _local1.k;
_local1._x = _local1._x + _local1.xmov;
_local1._y = _local1._y + _local1.ymov;
if ((Math.abs(_local1.xmov) < 1) && (Math.abs(_local1.ymov) < 1)) {
_local1._x = _local1.homex;
_local1._y = _local1.homey;
_local1.game.doneSlidingBack();
_local1.onEnterFrame = null;
}
};
cell1.clip.onEnterFrame = _local2;
_local3.clip.onEnterFrame = _local2;
};
game.swapPlaces = function () {
var _local1 = this;
_local1.slid = 0;
var _local3 = _local1.selected[0];
var _local2 = _local1.selected[1];
_local3.clip.select._visible = false;
_local2.clip.select._visible = false;
_local3.clip.x = _local2.clip._x;
_local3.clip.homex = _local3.clip._x;
_local2.clip.homex = _local2.clip._x;
_local3.clip.homey = _local3.clip._y;
_local2.clip.homey = _local2.clip._y;
_local3.clip.y = _local2.clip._y;
_local3.clip.k = 0.3;
_local2.clip.k = 0.3;
_local2.clip.x = _local3.clip._x;
_local2.clip.y = _local3.clip._y;
_local3.clip.go = true;
_local2.clip.go = true;
_local3.clip.game = _local1;
_local2.clip.game = _local1;
var tempFunction = function () {
var _local1 = this;
if (_local1.go) {
_local1.xmov = (_local1.x - _local1._x) * _local1.k;
_local1.ymov = (_local1.y - _local1._y) * _local1.k;
_local1._x = _local1._x + _local1.xmov;
_local1._y = _local1._y + _local1.ymov;
if ((Math.abs(_local1.xmov) < 1) && (Math.abs(_local1.ymov) < 1)) {
_local1._x = _local1.x;
_local1._y = _local1.y;
_local1.game.doneSliding();
_local1.go = false;
}
}
};
_local3.clip.onEnterFrame = tempFunction;
_local2.clip.onEnterFrame = tempFunction;
};
game.addToMatch = function (which) {
var _local2 = this;
var okToInsert = true;
var _local3 = which;
var _local1 = 0;
while (_local1 < _local2.matched.length) {
if ((_local2.matched[_local1].x == _local3.x) && (_local2.matched[_local1].y == _local3.y)) {
var okToInsert = false;
}
_local1++;
}
if (okToInsert) {
_local2.matched.push(which);
}
};
game.checkForMatches = function () {
var _local1 = this;
var returnVal = false;
_local1.matched = [];
var i = 1;
while (i <= _local1.width) {
var _local3 = 1;
while (_local3 <= _local1.height) {
var matchFound = false;
var _local2 = _local1[(("cell" + i) + "_") + _local3];
var rightCell1 = _local1[(("cell" + (i + 1)) + "_") + _local3];
var rightCell2 = _local1[(("cell" + (i + 2)) + "_") + _local3];
var rightCell3 = _local1[(("cell" + (i + 3)) + "_") + _local3];
var rightCell4 = _local1[(("cell" + (i + 4)) + "_") + _local3];
var bottomCell1 = _local1[(("cell" + i) + "_") + (_local3 + 1)];
var bottomCell2 = _local1[(("cell" + i) + "_") + (_local3 + 2)];
var bottomCell3 = _local1[(("cell" + i) + "_") + (_local3 + 3)];
var bottomCell4 = _local1[(("cell" + i) + "_") + (_local3 + 4)];
if ((_local2.type == rightCell1.type) && (_local2.type == rightCell2.type)) {
var matchFound = true;
_local1.addToMatch(_local2);
_local1.addToMatch(rightCell1);
_local1.addToMatch(rightCell2);
if (_local2.type == rightCell3.type) {
_local1.addToMatch(rightCell3);
}
if ((_local2.type == rightCell3.type) && (_local2.type == rightCell4.type)) {
_local1.addToMatch(rightCell4);
}
returnVal = true;
}
if ((_local2.type == bottomCell1.type) && (_local2.type == bottomCell2.type)) {
var matchFound = true;
_local1.addToMatch(_local2);
_local1.addToMatch(bottomCell1);
_local1.addToMatch(bottomCell2);
if (_local2.type == bottomCell3.type) {
_local1.addToMatch(bottomCell3);
}
if ((_local2.type == bottomCell3.type) && (_local2.type == bottomCell4.type)) {
_local1.addToMatch(bottomCell4);
}
returnVal = true;
}
_local3++;
}
i++;
}
return(returnVal);
};
game.areThereMatches = function () {
var _local1 = this;
var valid = false;
var b = 0;
while (b < 2) {
var m = 1;
while (m <= _local1.height) {
var n = 1;
while (n <= _local1.width) {
if (b == 0) {
var tempx1 = n;
var tempy1 = m;
var tempx2 = (tempx1 + 1);
var tempy2 = tempy1;
} else {
var tempx1 = n;
var tempy1 = m;
var tempx2 = tempx1;
var tempy2 = (tempy1 + 1);
}
var _local3 = _local1[(("cell" + tempx1) + "_") + tempy1];
var _local2 = _local1[(("cell" + tempx2) + "_") + tempy2];
var valid = false;
var oldCell1 = _local3;
var oldCell2 = _local2;
var cell1Name = _local3.name;
var cell2Name = _local2.name;
if ((_local3.x == _local2.x) && (((_local3.y - 1) == _local2.y) || ((_local3.y + 1) == _local2.y))) {
_local1[oldCell1.name] = oldCell2;
_local1[oldCell2.name] = oldCell1;
var valid = _local1.checkForMatches();
}
if ((_local3.y == _local2.y) && (((_local3.x - 1) == _local2.x) || ((_local3.x + 1) == _local2.x))) {
_local1[oldCell1.name] = oldCell2;
_local1[oldCell2.name] = oldCell1;
var valid = _local1.checkForMatches();
}
_local1[oldCell1.name] = oldCell1;
_local1[oldCell2.name] = oldCell2;
if (valid) {
break;
}
n++;
}
if (valid) {
break;
}
m++;
}
if (valid) {
break;
}
b++;
}
if (valid) {
trace("x1=" + tempx1);
trace("y1=" + tempy1);
trace("x2=" + tempx2);
trace("y2=" + tempy2);
if (_root.checkAvailable == true) {
_local1[(("cell" + tempx1) + "_") + tempy1].clip.donut.gotoAndPlay(10);
_local1[(("cell" + tempx2) + "_") + tempy2].clip.donut.gotoAndPlay(10);
_root.currentTime = _root.currentTime - 50;
_root.checkAvailable = false;
}
} else {
_root.gotoAndPlay("noMove");
}
};
game.verifySelections = function () {
var _local1 = this;
var _local3 = _local1.selected[0];
var _local2 = _local1.selected[1];
var valid = false;
var oldCell1 = _local3;
var oldCell2 = _local2;
var cell1Name = _local3.name;
var cell2Name = _local2.name;
if ((_local3.x == _local2.x) && (((_local3.y - 1) == _local2.y) || ((_local3.y + 1) == _local2.y))) {
_local1[oldCell1.name] = oldCell2;
_local1[oldCell2.name] = oldCell1;
var valid = _local1.checkForMatches();
}
if ((_local3.y == _local2.y) && (((_local3.x - 1) == _local2.x) || ((_local3.x + 1) == _local2.x))) {
_local1[oldCell1.name] = oldCell2;
_local1[oldCell2.name] = oldCell1;
var valid = _local1.checkForMatches();
}
if (!valid) {
_local1[oldCell1.name] = oldCell1;
_local1[oldCell2.name] = oldCell2;
_local3.clip.select._visible = false;
_local2.clip.select._visible = false;
} else {
var x1 = _local1[cell1Name].x;
var y1 = _local1[cell1Name].y;
var x2 = _local1[cell2Name].x;
var y2 = _local1[cell2Name].y;
_local1[cell1Name].x = x2;
_local1[cell1Name].y = y2;
_local1[cell2Name].x = x1;
_local1[cell2Name].y = y1;
_local1[cell1Name].name = cell1Name;
_local1[cell2Name].name = cell2Name;
}
return(valid);
};
game.board.onMouseDown = function () {
var _local1 = this;
if (_root.notBusy == true) {
if (_local1.hitTest(_local1._parent._xmouse, _local1._parent._ymouse)) {
_local1.game.selectItem(_local1._xmouse, _local1._ymouse);
}
}
};
game.addClip = function (who) {
var _local1 = who;
var _local2 = this;
var newDepth = (++_local2.depth);
var _local3 = "donut" + newDepth;
_local2.board.attachMovie("donut", _local3, newDepth);
_local1.clip = _local2.board[_local3];
_local1.clip._x = (_local1.x - 0.5) * _local2.xspacing;
_local1.clip._y = (_local1.y - 0.5) * _local2.yspacing;
_local1.clip.gotoAndStop(_local1.type);
};
game.generateBoard = function () {
var _local1 = this;
var _local3 = 1;
while (_local3 <= _local1.width) {
var _local2 = 1;
while (_local2 <= _local1.height) {
var name = ((("cell" + _local3) + "_") + _local2);
var leftCell = ((("cell" + (_local3 - 1)) + "_") + _local2);
var farLeftCell = ((("cell" + (_local3 - 2)) + "_") + _local2);
var topCell = ((("cell" + _local3) + "_") + (_local2 - 1));
var farTopCell = ((("cell" + _local3) + "_") + (_local2 - 2));
var keepLooking = true;
while (keepLooking) {
var keepLooking = false;
var type = (random(_local1.types) + 1);
if (((_local1[leftCell].type == type) && (_local1[farLeftCell].type == type)) || ((_local1[topCell].type == type) && (_local1[farTopCell].type == type))) {
var keepLooking = true;
}
}
_local1[name] = {x:_local3, y:_local2, name:name, type:type};
_local1.addClip(_local1[name]);
_local2++;
}
_local3++;
}
};
game.generateBoard();
stop();
Frame 7
_root.notBusy = false;
trace("next lvl");
stop();
Frame 8
_root.notBusy = false;
stop();
Frame 9
_root.notBusy = true;
_root.numoftype = Number(_root.numoftype) + Number(1);
_root.lvl = Number(_root.lvl) + Number(1);
_root.txt1 = Number(0);
_root.txt2 = Number(0);
_root.txt3 = Number(0);
_root.txt4 = Number(0);
_root.txt5 = Number(0);
_root.txt6 = Number(0);
_root.txt7 = Number(0);
_root.txt8 = Number(0);
_root.txt9 = Number(0);
gotoAndPlay (3);
Frame 10
removeMovieClip(this.board.fruit);
Frame 11
_root.notBusy = true;
_root.numoftype = Number(_root.numoftype) + Number(1);
_root.lvl = Number(_root.lvl) + Number(1);
i = 1;
while (i < 10) {
_root["max" + i] = Number(_root["max" + i]) + Number(5);
i++;
}
_root.txt1 = Number(0);
_root.txt2 = Number(0);
_root.txt3 = Number(0);
_root.txt4 = Number(0);
_root.txt5 = Number(0);
_root.txt6 = Number(0);
_root.txt7 = Number(0);
_root.txt8 = Number(0);
_root.txt9 = Number(0);
_root["order" + _root.numoftype]._alpha = 100;
_root.tick1.gotoAndStop(1);
_root.tick2.gotoAndStop(1);
_root.tick3.gotoAndStop(1);
_root.tick4.gotoAndStop(1);
_root.tick5.gotoAndStop(1);
_root.tick6.gotoAndStop(1);
_root.tick7.gotoAndStop(1);
_root.tick8.gotoAndStop(1);
_root.tick9.gotoAndStop(1);
gotoAndPlay ("actions");
Symbol 8 Button
on (release) {
getURL ("http://www.icreations.sg", "_blank");
}
Symbol 37 MovieClip Frame 1
frloaded = _root.getBytesLoaded();
frtotal = _root.getBytesTotal();
if (frloaded < frtotal) {
tellTarget ("_root") {
stop();
};
}
Symbol 37 MovieClip Frame 2
frloaded = _root.getBytesLoaded();
frtotal = _root.getBytesTotal();
if (frloaded < frtotal) {
percentloaded = ((int((frloaded / frtotal) * 100) + "%") + " ") + "loaded";
wbar.gotoAndStop(Math.ceil((frloaded / frtotal) * 100));
} else {
gotoAndPlay (5);
}
Symbol 37 MovieClip Frame 3
gotoAndPlay (2);
Symbol 37 MovieClip Frame 70
tellTarget ("_root") {
play();
};
Symbol 49 MovieClip Frame 1
stop();
Symbol 52 MovieClip Frame 1
stop();
Symbol 61 MovieClip Frame 1
stop();
Symbol 66 MovieClip Frame 1
stop();
Symbol 69 MovieClip Frame 1
stop();
Symbol 72 MovieClip Frame 1
stop();
Symbol 85 MovieClip Frame 1
stop();
Symbol 88 MovieClip Frame 1
stop();
Symbol 91 MovieClip Frame 1
stop();
Symbol 98 Button
on (release) {
gotoAndPlay ("start");
}
Symbol 111 MovieClip Frame 240
gotoAndPlay ("sound");
Symbol 115 Button
on (release) {
_root.bg.setVolume(0);
this.nextFrame();
}
Symbol 118 Button
on (release) {
_root.bg.setVolume(100);
this.prevFrame();
}
Symbol 146 MovieClip Frame 1
stop();
Symbol 146 MovieClip Frame 9
stop();
Symbol 146 MovieClip Frame 10
this.prevFrame();
Symbol 155 Button
on (press) {
_root.checkAvailable = true;
}
on (releaseOutside) {
_root.checkAvailable = false;
}
on (release) {
game.areThereMatches();
}
Symbol 160 MovieClip Frame 1
stop();
Symbol 160 MovieClip Frame 16
gotoAndStop (1);
Symbol 160 MovieClip Frame 32
gotoAndStop (1);
Symbol 163 Button
on (release) {
game.areThereMatches();
}
Symbol 164 MovieClip Frame 1
stop();
Symbol 164 MovieClip Frame 2
_root.order1.play();
Symbol 164 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 164 MovieClip Frame 21
gotoAndStop (1);
Symbol 165 MovieClip Frame 1
stop();
Symbol 165 MovieClip Frame 2
_root.order2.play();
Symbol 165 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 165 MovieClip Frame 21
gotoAndStop (1);
Symbol 166 MovieClip Frame 1
stop();
Symbol 166 MovieClip Frame 2
_root.order3.play();
Symbol 166 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 166 MovieClip Frame 21
gotoAndStop (1);
Symbol 167 MovieClip Frame 1
stop();
Symbol 167 MovieClip Frame 2
_root.order4.play();
Symbol 167 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 167 MovieClip Frame 21
gotoAndStop (1);
Symbol 168 MovieClip Frame 1
stop();
Symbol 168 MovieClip Frame 2
_root.order5.play();
Symbol 168 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 168 MovieClip Frame 21
gotoAndStop (1);
Symbol 169 MovieClip Frame 1
stop();
Symbol 169 MovieClip Frame 2
_root.order6.play();
Symbol 169 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 169 MovieClip Frame 21
gotoAndStop (1);
Symbol 170 MovieClip Frame 1
stop();
Symbol 170 MovieClip Frame 2
_root.order7.play();
Symbol 170 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 170 MovieClip Frame 21
gotoAndStop (1);
Symbol 171 MovieClip Frame 1
stop();
Symbol 171 MovieClip Frame 2
_root.order8.play();
Symbol 171 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 171 MovieClip Frame 21
gotoAndStop (1);
Symbol 172 MovieClip Frame 1
stop();
Symbol 172 MovieClip Frame 2
_root.order9.play();
Symbol 172 MovieClip Frame 9
game.removed(this._parent);
stop();
Symbol 172 MovieClip Frame 21
gotoAndStop (1);
Symbol 173 MovieClip [donut] Frame 1
stop();
select._visible = false;
Symbol 181 Button
on (release) {
_root.gotoAndPlay("restart");
}
Symbol 187 Button
on (release) {
_root.gotoAndPlay("start");
}
Symbol 192 Button
on (release) {
_root.gotoAndPlay("start");
}
Symbol 195 Button
on (release) {
_root.gotoAndPlay("start");
}