Frame 1
stop();
preloader.bar._xscale = 0;
this.onEnterFrame = function () {
preloader.bar._xscale = int((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
if (_root.getBytesLoaded() >= _root.getBytesTotal()) {
gotoAndStop (3);
delete this.onEnterFrame;
}
};
Frame 3
function Game() {
this.__init__();
}
function enableTiles() {
_root._game_.setEnabled(true);
}
function nextLevel() {
addScore(10);
_root._game_.start();
_root.enableTiles();
}
function addScore(sc) {
if (_root.score.text == "") {
_root.score.text = 0;
}
_game_.setScore(sc);
_root.score.text = _game_.getScore();
}
function restart() {
_game_.removeAll();
_game_.start();
_root.enableTiles();
}
function countDown() {
_game_.setTimer(_game_.getTimer() - 1);
time_left.text = _game_.formatTime(_game_.getTimer());
}
function timeUp() {
restart();
}
function restartSameLevel() {
restart();
}
function gameover() {
_game_.stopTimer();
_game_.removeAll();
gotoAndStop (3);
}
function startSound(s) {
eval (s).play();
}
_global.set_count = 18;
_global.level_count = 7;
_global.rows_count = 7;
_global.columns_count = 7;
_global.x_start = 180;
_global.y_start = 120;
_global.pieces_w = 40;
_global.pieces_h = 40;
theSound = new Sound();
Game.prototype.__init__ = function () {
this.$cookie = SharedObject.getLocal("neoTiles");
if (!(this.$cookie.data.record instanceof Array)) {
this.$cookie.data.record = new Array();
}
this.setLevel(1);
this.life_count = 3;
this.score = 0;
this.timer = this.getCurrentLevel() * 58;
this.$enabled = true;
this.floorArray = new Array();
this.availArray = new Array();
setSelected(undefined);
life.text = "x" + this.life_count;
};
Game.prototype.start = function () {
if ((this.life_count > 0) && (this.getCurrentLevel() <= level_count)) {
this.availArray = new Array();
this.setLevel(this.getCurrentLevel());
this.resetTimer(this.getCurrentLevel(), this.getPreviousTimer());
this.buildPanel(this.getCurrentLevel());
this.addMouseListener();
setSelected(undefined);
}
};
Game.prototype.addMouseListener = function () {
this.checkPieces();
};
Game.prototype.getPreviousTimer = function () {
return(this.$availableTime);
};
Game.prototype.checkPieces = function () {
var num = 0;
this.availArray = new Array();
for (var level in this.floorArray) {
num = num + this.floorArray[level].length;
for (var pieces in this.floorArray[level]) {
var x = Number(this.floorArray[level][pieces]._name.substr(7, 1));
var y = Number(this.floorArray[level][pieces]._name.substr(9, 1));
var previous = _root[(((("clip_" + level) + "_") + (x - 1)) + "_") + y];
var next = _root[(((("clip_" + level) + "_") + (x + 1)) + "_") + y];
if ((previous == undefined) || (next == undefined)) {
this.floorArray[level][pieces].gotoAndStop("normal");
var x = Number(this.floorArray[level][pieces]._name.substr(7, 1));
var y = Number(this.floorArray[level][pieces]._name.substr(9, 1));
var d = Number(this.floorArray[level][pieces]._name.substr(5, 1));
if (_root[(((("clip_" + (d + 1)) + "_") + x) + "_") + y] == undefined) {
this.availArray[this.floorArray[level][pieces].type] = this.availArray[this.floorArray[level][pieces].type] + 1;
}
}
}
}
if (num == 0) {
if (this.getCurretLevel() < level_count) {
this.setLevel(this.getCurrentLevel() + 1);
error_message("Compliments!\nPress OK to start level " + this.getCurrentLevel(), "nextLevel");
this.stopTimer();
}
}
return(num);
};
Game.prototype.buildPanel = function (level) {
var count = set_count;
var floor = level;
var x = x_start;
var y = y_start;
var total_pieces = 0;
var a = 1;
while (a <= 20) {
this.floorArray[a] = new Array();
a++;
}
if (floor == 1) {
var total_pieces = this.getRandom(columns_count * rows_count);
var a = 1;
while (a <= total_pieces) {
var piece = ("clip" + (random(_global.set_count) + 1));
var b = 0;
while (b < 2) {
k = 0;
do {
var match = false;
var posx = random(columns_count);
var posy = random(rows_count);
for (var line in this.floorArray[1]) {
if ((this.floorArray[1][line]._x == (x_start + (posx * pieces_w))) && (this.floorArray[1][line]._y == (y_start + (posy * pieces_h)))) {
match = true;
break;
}
}
} while (match == true);
var depth = (floor + (a + b));
var name = ("clip_1_" + (((posx + 1) + "_") + (posy + 1)));
_root.attachMovie(piece, name, depth);
_root[name]._x = x_start + (posx * pieces_w);
_root[name]._y = y_start + (posy * pieces_h);
_root[name].gotoAndStop("blocked");
this.floorArray[1].push(_root[name]);
b++;
}
a = a + 2;
}
} else {
var count = 1;
while (count <= floor) {
var total_pieces = this.getRandom((columns_count * rows_count) - (count * 2));
var a = 1;
while (a <= total_pieces) {
var piece = ("clip" + (random(_global.set_count) + 1));
var b = 0;
while (b < 2) {
k = 1;
var posx = random(columns_count);
var posy = random(rows_count);
while (_root[(((("clip_" + k) + "_") + (posx + 1)) + "_") + (posy + 1)] != undefined) {
k++;
}
var depth = (((k * 100) + ((posy + 1) * 10)) + (posx + 1));
var name = ((("clip_" + k) + "_") + (((posx + 1) + "_") + (posy + 1)));
_root.attachMovie(piece, name, depth);
_root[name]._x = (x_start + (posx * pieces_w)) - ((k - 1) * 3);
_root[name]._y = (y_start + (posy * pieces_h)) - ((k - 1) * 3);
_root[name].gotoAndStop("blocked");
this.floorArray[k].push(_root[name]);
name = undefined;
b++;
}
a = a + 2;
}
count++;
}
}
};
Game.prototype.getRandom = function (max) {
var total_pieces;
do {
total_pieces = random(max) + 1;
} while ((total_pieces < 10) || ((total_pieces % 2) == 1));
return(total_pieces);
};
Game.prototype.setLevel = function (lev) {
this.current_level = lev;
if (this.current_level > _global.level_count) {
this.stopTimer();
this.finishAll("gameover");
}
};
Game.prototype.getCurrentLevel = function () {
return(this.current_level);
};
Game.prototype.resetTimer = function (level, timer) {
this.stopTimer();
this.$availableTime = (level * 58) + Math.round(timer / 4);
this._$t_ = setInterval(countdown, 1000);
};
Game.prototype.formatTime = function (sec) {
var time = sec;
var min = Math.floor(sec / 60);
var seconds = (sec - (min * 60));
if (seconds < 10) {
seconds = "0" + seconds;
}
return(((min + "'") + seconds) + "''");
};
Game.prototype.setEnabled = function (bool) {
this.$enabled = bool;
};
Game.prototype.getEnabled = function () {
return(this.$enabled);
};
Game.prototype.getTimer = function () {
return(this.$availableTime);
};
Game.prototype.setTimer = function (t) {
this.$availableTime = t;
if (this.getTimer() <= 0) {
this.stopTimer();
this.die();
if (this.life_count < 1) {
this.saveScore(this.getCurrentLevel(), this.score);
error_message("Time UP", "gameover");
} else {
error_message("Time UP!\nPress ok to try again same level", "timeUp");
}
}
};
Game.prototype.finishAll = function (handler) {
this.stopTimer();
error_message("Compliments! You finish all levels", handler);
this.saveScore(this.getCurrentLevel(), this.score);
};
Game.prototype.die = function () {
this.life_count--;
if (this.life_count <= 0) {
return(false);
}
life.text = "x" + this.life_count;
return(true);
};
Game.prototype.removeAll = function () {
for (var a in this.floorArray) {
for (var b in this.floorArray[a]) {
this.floorArray[a][b].removeMovieClip();
}
}
this.floorArray = new Array();
this.availArray = new Array();
};
Game.prototype.canContinue = function () {
for (var a in this.availArray) {
if (this.availArray[a] > 1) {
return(true);
}
}
return(false);
};
Game.prototype.stopTimer = function () {
clearInterval(this._$t_);
clearInterval(this._finish_);
};
Game.prototype.saveScore = function (level, sc) {
this.$cookie.data.record.push([level, sc]);
this.$cookie.flush();
};
Game.prototype.getRecords = function () {
var mySortFn = function (element1, element2) {
return(element2[1] - element1[1]);
};
return(this.$cookie.data.record.sort(mySortFn));
};
Game.prototype.setScore = function (sc) {
this.score = this.score + sc;
};
Game.prototype.getScore = function () {
return(this.score);
};
_global.setSelected = function (clip) {
if (clip == undefined) {
_global.selected = undefined;
return(undefined);
}
if (clip == selected) {
return(true);
}
if ((clip.type == selected.type) && (clip != selected)) {
for (var a in _game_.floorArray) {
for (var b in _game_.floorArray[a]) {
if (_game_.floorArray[a][b] == clip) {
_game_.floorArray[a].splice(b, 1);
break;
}
}
}
for (var a in _game_.floorArray) {
for (var b in _game_.floorArray[a]) {
if (_game_.floorArray[a][b] == selected) {
_game_.floorArray[a].splice(b, 1);
break;
}
}
}
clip.removeMovieClip();
selected.removeMovieClip();
addScore(1);
_global.selected = undefined;
startSound("pushed");
var num = _game_.checkPieces();
if ((!_game_.canContinue()) && (num > 0)) {
_game_.stopTimer();
_game_.die();
if (_game_.life_count < 1) {
_root._game_.saveScore(_root._game_.getCurrentLevel(), _root._game_.score);
error_message("Sorry!\nNo more matching tiles available...", "gameover");
} else {
error_message("Sorry!\nNo more matching tiles available.. ok to try same level", "restartSameLevel");
}
return(false);
}
return(true);
}
if ((clip.type != selected.type) && (selected != undefined)) {
return(false);
}
_global.selected = clip;
return(true);
};
_global.error_message = function (msg, handler) {
_root._game_.setEnabled(false);
_root.attachMovie("floating_window", "floating_window", 1234567);
_root.floating_window._x = 150;
_root.floating_window._y = 150;
_root.floating_window.message.text = msg;
_root.floating_window.closeHandler = handler;
_root.floating_window.obj = _root;
};
stop();
Frame 4
_game_ = new Game();
_game_.start();
var record = _game_.getRecords();
var a = 0;
while (a < 10 , a < record.length) {
_root.record_txt.text = _root.record_txt.text + (((((((a + 1) + ". ") + record[a][1]) + " (level ") + record[a][0]) + ")") + newline);
a++;
}
stop();
Frame 5
stop();
Symbol 5 Button
on (press) {
this.startDrag(false);
}
on (release, releaseOutside) {
stopDrag();
}
Symbol 13 Button
on (release) {
this.unloadMovie();
this[obj][closeHandler]();
}
Symbol 16 MovieClip [floating_window] Frame 1
_hidden.useHandCursor = false;
Symbol 23 Button
on (release) {
var x = Number(this._name.substr(7, 1));
var y = Number(this._name.substr(9, 1));
var d = Number(this._name.substr(5, 1));
if (_root[(((("clip_" + (d + 1)) + "_") + x) + "_") + y] != undefined) {
return(undefined);
}
if (_root._game_.getEnabled() == false) {
return(undefined);
}
if (_currentframe == 1) {
if (setSelected(this)) {
gotoAndStop (3);
} else {
error_message("Select matching tiles only!", "enableTiles");
}
return(undefined);
}
if (_currentframe == 3) {
setSelected(undefined);
gotoAndStop (1);
return(undefined);
}
error_message("Dark tiles are blocked.\nSelect light tiles only", "enableTiles");
}
Symbol 30 MovieClip [clip1] Frame 1
this.type = 1;
stop();
Symbol 33 MovieClip [clip2] Frame 1
this.type = 2;
stop();
Symbol 36 MovieClip [clip3] Frame 1
this.type = 3;
stop();
Symbol 39 MovieClip [clip4] Frame 1
this.type = 4;
stop();
Symbol 44 MovieClip [clip5] Frame 1
this.type = 5;
stop();
Symbol 48 MovieClip [clip6] Frame 1
this.type = 6;
stop();
Symbol 51 MovieClip [clip7] Frame 1
this.type = 7;
stop();
Symbol 54 MovieClip [clip8] Frame 1
this.type = 8;
stop();
Symbol 57 MovieClip [clip9] Frame 1
this.type = 9;
stop();
Symbol 60 MovieClip [clip10] Frame 1
this.type = 10;
stop();
Symbol 63 MovieClip [clip11] Frame 1
this.type = 11;
stop();
Symbol 68 MovieClip [clip12] Frame 1
this.type = 12;
stop();
Symbol 71 MovieClip [clip13] Frame 1
this.type = 13;
stop();
Symbol 74 MovieClip [clip14] Frame 1
this.type = 14;
stop();
Symbol 77 MovieClip [clip15] Frame 1
this.type = 15;
stop();
Symbol 80 MovieClip [clip16] Frame 1
this.type = 16;
stop();
Symbol 83 MovieClip [clip17] Frame 1
this.type = 17;
stop();
Symbol 86 MovieClip [clip18] Frame 1
this.type = 18;
stop();
Symbol 94 Button
on (release) {
_root.floating_window.unloadMovie();
gotoAndStop (4);
}
Symbol 98 Button
on (release) {
error_message(("Complete all " + level_count) + " levels removing tiles on the screen. Select a couple of light tiles to remove them", "");
}
Symbol 115 Button
on (release) {
getURL ("http://www.sephiroth.it", "_blank");
}
Symbol 117 MovieClip Frame 1
stop();
Symbol 118 Button
on (release) {
_root.floating_window.unloadMovie();
gotoAndStop (3);
}