Frame 1
_global.stage_mc = this;
_global.preloader = function () {
bytesTotal = _root.getBytesTotal();
bytesLoaded = _root.getBytesLoaded();
if (bytesLoaded >= bytesTotal) {
gotoAndStop ("start");
} else {
percent_mc.percentBar_mc._width = (bytesLoaded / bytesTotal) * 100;
gotoAndPlay ("preload");
}
};
_global.preloader2 = function () {
if (percent_mc.percentBar_mc._width >= 100) {
gotoAndStop ("start");
} else {
percent_mc.percentBar_mc._width = percent_mc.percentBar_mc._width + 1;
gotoAndPlay ("preload");
}
};
_global.preloader();
Frame 2
_global.preloader();
Frame 21
function checkStage() {
var _local1 = _global;
rowBonus = 0;
row = 19;
while (row >= 0) {
if (((((((((_local1.stage_array[row][0] && (_local1.stage_array[row][1])) && (_local1.stage_array[row][2])) && (_local1.stage_array[row][3])) && (_local1.stage_array[row][4])) && (_local1.stage_array[row][5])) && (_local1.stage_array[row][6])) && (_local1.stage_array[row][7])) && (_local1.stage_array[row][8])) && (_local1.stage_array[row][9])) {
_local1.score = _local1.score + 10;
_local1.clearedLines++;
rowBonus++;
inCol = 0;
while (inCol < 10) {
mainWindow_mc[(("tile" + row.toString()) + "|") + inCol.toString()].removeMovieClip();
inCol++;
}
inRow = row;
while (inRow >= 0) {
inCol = 0;
while (inCol < 10) {
_local1.stage_array[inRow][inCol] = _local1.stage_array[inRow - 1][inCol];
if (_local1.stage_array[inRow - 1][inCol]) {
mainWindow_mc.attachMovie("tile" + mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()].saveColor, (("tile" + inRow.toString()) + "|") + inCol.toString(), _local1.depth++);
mainWindow_mc[(("tile" + inRow.toString()) + "|") + inCol.toString()].saveColor = mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()].saveColor;
mainWindow_mc[(("tile" + inRow.toString()) + "|") + inCol.toString()]._x = mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()]._x;
mainWindow_mc[(("tile" + inRow.toString()) + "|") + inCol.toString()]._y = mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()]._y + 20;
mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()].removeMovieClip();
}
inCol++;
}
inRow--;
}
col = 0;
while (col < 10) {
_local1.stage_array[0][col] = 0;
col++;
}
row++;
}
row--;
}
if (rowBonus > 1) {
_local1.score = _local1.score + (rowBonus * 5);
}
if (rowBonus == 1) {
line1_sound.start();
} else if (rowBonus == 2) {
line2_sound.start();
} else if (rowBonus == 3) {
line3_sound.start();
} else if (rowBonus == 4) {
line4_sound.start();
}
}
function changePiece() {
var _local1 = _global;
if (_local1.currentPiece != null) {
pieces[_local1.currentPiece].setNext();
change_sound.start();
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece].removeMovieClip();
}
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local1.currentPiece].getArray()[row][col]) {
mainWindow_mc.attachMovie("tile" + _local1.lastColor, (("piece" + row.toString()) + "|") + col.toString(), _local1.depth++);
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()].saveColor = pieceColor;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._x = (col + _local1.currentPiece_col) * 20;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._y = (row + _local1.currentPiece_row) * 20;
}
col++;
}
row++;
}
}
updateHelpBar();
}
function drawPiece(moveDiag) {
var _local1 = _global;
if (_local1.currentPiece == null) {
if (_local1.nextPiece == null) {
_local1.currentPiece = Math.floor(Math.random() * 7);
_local1.nextPiece = Math.floor(Math.random() * 7);
pieceColor = Number(Math.floor(Math.random() * 5) + 1);
_local1.lastColor = pieceColor;
do {
_local1.nextPieceColor = Number(Math.floor(Math.random() * 5) + 1);
} while (_local1.nextPieceColor == pieceColor);
updatePreview();
} else {
_local1.currentPiece = _local1.nextPiece;
pieceColor = (_local1.lastColor = _local1.nextPieceColor);
_local1.nextPiece = Math.floor(Math.random() * 7);
do {
_local1.nextPieceColor = Number(Math.floor(Math.random() * 5) + 1);
} while (_local1.nextPieceColor == pieceColor);
updatePreview();
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local1.currentPiece].getArray()[row][col] && (_local1.stage_array[_local1.currentPiece_row + row][_local1.currentPiece_col + col])) {
_local1.runGame = false;
_local1.gameOver = true;
showGameOverWindow();
}
col++;
}
row++;
}
if (_local1.runGame) {
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local1.currentPiece].getArray()[row][col]) {
mainWindow_mc.attachMovie("tile" + pieceColor, (("piece" + row.toString()) + "|") + col.toString(), _local1.depth++);
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()].saveColor = pieceColor;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._x = (col + _local1.currentPiece_col) * 20;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._y = (row + _local1.currentPiece_row) * 20;
}
col++;
}
row++;
}
updateHelpBar();
}
} else if ((_local1.speedCnt >= _local1.speed) || (moveDiag)) {
if (moveDownCheck()) {
if (!moveDiag) {
_local1.currentPiece_row++;
_local1.speedCnt = 0;
}
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece]._x = (Number(piece.toString().substr(7, 1)) * 20) + (_local1.currentPiece_col * 20);
mainWindow_mc[piece]._y = (Number(piece.toString().substr(5, 1)) * 20) + (_local1.currentPiece_row * 20);
}
}
} else {
_local1.score = _local1.score + 2;
drop_sound.start();
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local1.currentPiece].getArray()[row][col]) {
_local1.stage_array[_local1.currentPiece_row + row][col + _local1.currentPiece_col] = pieces[_local1.currentPiece].getArray()[row][col];
}
col++;
}
row++;
}
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece]._x = (Number(piece.toString().substr(7, 1)) * 20) + (_local1.currentPiece_col * 20);
mainWindow_mc[piece]._y = (Number(piece.toString().substr(5, 1)) * 20) + (_local1.currentPiece_row * 20);
}
}
_local1.currentPiece = null;
_local1.currentPiece_row = 0;
_local1.currentPiece_col = 4;
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
tempRow = mainWindow_mc[piece]._y / 20;
tempCol = mainWindow_mc[piece]._x / 20;
mainWindow_mc.attachMovie("tile" + mainWindow_mc[piece].saveColor, (("tile" + tempRow) + "|") + tempCol, _local1.depth++);
mainWindow_mc[(("tile" + tempRow) + "|") + tempCol]._x = mainWindow_mc[piece]._x;
mainWindow_mc[(("tile" + tempRow) + "|") + tempCol]._y = mainWindow_mc[piece]._y;
mainWindow_mc[(("tile" + tempRow) + "|") + tempCol].saveColor = mainWindow_mc[piece].saveColor;
mainWindow_mc[piece].removeMovieClip();
}
}
updateHelpBar();
}
} else {
_local1.speedCnt++;
}
}
function updateHelpBar() {
var _local1 = _global;
farCol = 0;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local1.currentPiece].getArray()[row][col] && (farCol < col)) {
farCol = col;
}
col++;
}
row++;
}
helpBarWindow_mc.helpBar_mc._x = _local1.currentPiece_col * 20;
helpBarWindow_mc.helpBar_mc._width = (farCol + 1) * 20;
}
function updatePreview() {
var _local1 = _global;
for (piece_mc in previewWindow_mc) {
previewWindow_mc[piece_mc].removeMovieClip();
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local1.nextPiece].getArray()[row][col]) {
previewWindow_mc.attachMovie("tile" + _local1.nextPieceColor, (("piece" + row.toString()) + "|") + col.toString(), _local1.depth++);
previewWindow_mc[(("piece" + row.toString()) + "|") + col.toString()].saveColor = pieceColor;
previewWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._x = col * 20;
previewWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._y = row * 20;
}
col++;
}
row++;
}
}
function dropPiece() {
var _local1 = _global;
while (moveDownCheck()) {
_local1.currentPiece_row++;
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece]._x = (Number(piece.toString().substr(7, 1)) * 20) + (_local1.currentPiece_col * 20);
mainWindow_mc[piece]._y = (Number(piece.toString().substr(5, 1)) * 20) + (_local1.currentPiece_row * 20);
}
}
}
_local1.speedCnt = 0;
drawPiece();
}
function moveDownCheck() {
var _local1 = _global;
var _local2 = true;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if ((pieces[_local1.currentPiece].getArray()[row][col] && (_local1.stage_array[(_local1.currentPiece_row + row) + 1][col + _local1.currentPiece_col])) || (pieces[_local1.currentPiece].getArray()[row][col] && (((_local1.currentPiece_row + row) + 1) >= 20))) {
_local2 = false;
}
col++;
}
row++;
}
return(_local2);
}
function moveLeftCheck() {
var _local1 = _global;
var _local2 = true;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if ((pieces[_local1.currentPiece].getArray()[row][col] && (_local1.stage_array[_local1.currentPiece_row + row][(col + _local1.currentPiece_col) - 1])) || (_local1.currentPiece_col <= 0)) {
_local2 = false;
}
col++;
}
row++;
}
return(_local2);
}
function moveRightCheck() {
var _local1 = _global;
var _local2 = true;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if ((pieces[_local1.currentPiece].getArray()[row][col] && (_local1.stage_array[_local1.currentPiece_row + row][(col + _local1.currentPiece_col) + 1])) || (pieces[_local1.currentPiece].getArray()[row][col] && (((col + _local1.currentPiece_col) + 1) > 9))) {
_local2 = false;
}
col++;
}
row++;
}
return(_local2);
}
function pauseGame() {
var _local1 = _global;
if ((_local1.currentPiece != null) && (!_local1.gameOver)) {
_local1.runGame = !_local1.runGame;
pause_sound.start();
if (_local1.runGame) {
stage_mc.pauseSign_mc.removeMovieClip();
} else {
stage_mc.attachMovie("pauseSign", "pauseSign_mc", depth++);
stage_mc.pauseSign_mc._x = 70;
stage_mc.pauseSign_mc._y = 200;
}
}
}
function playMusic() {
var _local1 = _global;
stage_mc.title_mc.removeMovieClip();
stage_mc.attachMovie("title" + _local1.currentMusic, "title_mc", depth++);
stage_mc.title_mc._x = 12;
stage_mc.title_mc._y = 420;
if (_local1.currentMusic == 1) {
music1_sound.start();
music1_sound.onSoundComplete = function () {
music1_sound.start();
};
} else if (_local1.currentMusic == 2) {
music2_sound.start();
music2_sound.onSoundComplete = function () {
music2_sound.start();
};
} else if (_local1.currentMusic == 3) {
music3_sound.start();
music3_sound.onSoundComplete = function () {
music3_sound.start();
};
}
}
function showGameOverWindow() {
if (!_global.windowUp) {
stage_mc.attachMovie("gameOverWindow", "gameOverWindow_mc", depth++);
stage_mc.gameOverWindow_mc._x = 175;
stage_mc.gameOverWindow_mc._y = 100;
_global.windowUp = true;
}
}
function stopMusic() {
var _local1 = _global;
if (_local1.currentMusic == 1) {
music1_sound.stop("Bliss");
} else if (_local1.currentMusic == 2) {
music2_sound.stop("music2.wav");
} else if (_local1.currentMusic == 3) {
music3_sound.stop("music3.wav");
}
}
_global.highScoresScript = "http://www.emeraldtokyo.com/tetris.php";
change_sound = new Sound();
change_sound.attachSound("Woah");
drop_sound = new Sound();
drop_sound.attachSound("Wow");
pause_sound = new Sound();
pause_sound.attachSound("Clicka");
start_sound = new Sound();
start_sound.attachSound("Clicka");
levelUp_sound = new Sound();
levelUp_sound.attachSound("Mach");
line1_sound = new Sound();
line1_sound.attachSound("Boom");
line2_sound = new Sound();
line2_sound.attachSound("Boom");
line3_sound = new Sound();
line3_sound.attachSound("Boom");
line4_sound = new Sound();
line4_sound.attachSound("Echo");
music1_sound = new Sound();
music1_sound.attachSound("Bliss");
music2_sound = new Sound();
music2_sound.attachSound("music2.wav");
music3_sound = new Sound();
music3_sound.attachSound("music3.wav");
_global.currentMusic = 2;
_global.depth = 0;
_global.runGame = false;
_global.gameOver = false;
_global.score = 0;
_global.level = 0;
_global.levelChange = 20;
_global.clearedLines = 0;
_global.speed = 18;
_global.speedCnt = 0;
_global.currentPiece = null;
_global.nextPiece = null;
_global.nextPieceColor = 0;
_global.currentPiece_row = 0;
_global.currentPiece_col = 4;
_global.lastColor = 0;
_global.windowUp = false;
_global.stage_array = new Array();
_global.stage_array = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
Piece = function (newPiece) {
this.piece_array = newPiece;
};
Piece.prototype.setNext = function () {
var _local1 = this;
temp_array = new Array();
temp_array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
temp_array[col][3 - row] = _local1.piece_array[row][col];
col++;
}
row++;
}
_local1.piece_array = temp_array;
while (!(((_local1.piece_array[0][0] || (_local1.piece_array[1][0])) || (_local1.piece_array[2][0])) || (_local1.piece_array[3][0]))) {
row = 0;
while (row < 4) {
col = 1;
while (col < 4) {
_local1.piece_array[row][col - 1] = _local1.piece_array[row][col];
col++;
}
row++;
}
_local1.piece_array[0][3] = 0;
_local1.piece_array[1][3] = 0;
_local1.piece_array[2][3] = 0;
_local1.piece_array[3][3] = 0;
}
};
Piece.prototype.testNext = function () {
var _local1 = _global;
var _local2 = this;
returnBool = true;
temp_array = new Array();
temp_array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
temp_array[col][3 - row] = _local2.piece_array[row][col];
col++;
}
row++;
}
while (!(((temp_array[0][0] || (temp_array[1][0])) || (temp_array[2][0])) || (temp_array[3][0]))) {
row = 0;
while (row < 4) {
col = 1;
while (col < 4) {
temp_array[row][col - 1] = temp_array[row][col];
col++;
}
row++;
}
temp_array[0][3] = 0;
temp_array[1][3] = 0;
temp_array[2][3] = 0;
temp_array[3][3] = 0;
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (((temp_array[row][col] && (_local1.stage_array[row + _local1.currentPiece_row][col + _local1.currentPiece_col])) || (temp_array[row][col] && ((col + _local1.currentPiece_col) > 9))) || (temp_array[row][col] && ((row + _local1.currentPiece_row) > 19))) {
returnBool = false;
}
col++;
}
row++;
}
return(returnBool);
};
Piece.prototype.getArray = function () {
return(this.piece_array);
};
pieces = new Array();
pieces.push(new Piece([[1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[1, 1, 1, 0], [0, 0, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[0, 0, 1, 0], [1, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[0, 1, 0, 0], [1, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[0, 1, 0, 0], [1, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]]));
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local1 = _global;
if (_local1.runGame && (_local1.currentPiece != null)) {
if (Key.isDown(37)) {
if (moveLeftCheck()) {
_local1.currentPiece_col--;
}
drawPiece(true);
updateHelpBar();
} else if (Key.isDown(39)) {
if (moveRightCheck()) {
_local1.currentPiece_col++;
}
drawPiece(true);
updateHelpBar();
} else if (Key.isDown(38)) {
if (pieces[_local1.currentPiece].testNext()) {
changePiece();
}
} else if (Key.isDown(40)) {
dropPiece();
}
}
};
Key.addListener(keyListener);
playMusic();
stage_mc.createEmptyMovieClip("scoreWindow_mc", depth++);
stage_mc.scoreWindow_mc._x = 260;
stage_mc.scoreWindow_mc._y = 375;
stage_mc.scoreWindow_mc.score = -1;
stage_mc.createEmptyMovieClip("levelWindow_mc", depth++);
stage_mc.levelWindow_mc._x = 260;
stage_mc.levelWindow_mc._y = 275;
stage_mc.scoreWindow_mc.onEnterFrame = function () {
var _local1 = _global;
if (stage_mc.scoreWindow_mc.score < _local1.score) {
stage_mc.scoreWindow_mc.score++;
for (num in stage_mc.scoreWindow_mc) {
stage_mc.scoreWindow_mc[num].removeMovieClip();
}
newNumString = "000000".concat(stage_mc.scoreWindow_mc.score.toString()).substring(stage_mc.scoreWindow_mc.score.toString().length + 1, stage_mc.scoreWindow_mc.score.toString().length + 6);
pos = 0;
while (pos < newNumString.length) {
stage_mc.scoreWindow_mc.attachMovie("num" + newNumString.substr(pos, 1), "num" + pos, depth++);
stage_mc.scoreWindow_mc["num" + pos]._x = pos * 25;
stage_mc.scoreWindow_mc["num" + pos]._y = 0;
pos++;
}
if ((_local1.clearedLines >= _local1.levelChange) || (_local1.level == 0)) {
for (num in stage_mc.levelWindow_mc) {
stage_mc.levelWindow_mc[num].removeMovieClip();
}
_local1.level++;
if (_local1.level != 1) {
levelUp_sound.start();
}
_local1.clearedLines = 0;
if (_local1.speed >= 0) {
_local1.speed--;
}
newNumString = "00".concat(_local1.level.toString()).substring(_local1.level.toString().length, _local1.level.toString().length + 2);
pos = 0;
while (pos < newNumString.length) {
stage_mc.levelWindow_mc.attachMovie("num" + newNumString.substr(pos, 1), "num" + pos, depth++);
stage_mc.levelWindow_mc["num" + pos]._x = pos * 25;
stage_mc.levelWindow_mc["num" + pos]._y = 0;
pos++;
}
}
}
};
stage_mc.pauseGame_btn.onPress = function () {
if (!_global.windowUp) {
pauseGame();
}
};
stage_mc.pause_mc.onPress = function () {
stopMusic();
};
stage_mc.play_mc.onPress = function () {
playMusic();
};
stage_mc.ff_mc.onPress = function () {
stopMusic();
if ((++_global.currentMusic) > 3) {
_global.currentMusic = 1;
}
playMusic();
};
stage_mc.rewind_mc.onPress = function () {
stopMusic();
if ((--_global.currentMusic) < 1) {
_global.currentMusic = 3;
}
playMusic();
};
stage_mc.highScores_btn.onPress = function () {
var _local1 = _global;
if (_local1.runGame) {
pauseGame();
}
if (!_local1.windowUp) {
stage_mc.attachMovie("highScoresWindow", "highScoresWindow_mc", depth++);
stage_mc.highScoresWindow_mc._x = 175;
stage_mc.highScoresWindow_mc._y = 100;
_local1.windowUp = true;
}
};
stage_mc.newGame_btn.onPress = function () {
var _local1 = _global;
if (!_local1.windowUp) {
start_sound.start();
_local1.runGame = true;
_local1.gameOver = false;
_local1.score = 0;
_local1.level = 0;
_local1.clearedLines = 0;
_local1.speed = 18;
_local1.speedCnt = 0;
stage_mc.scoreWindow_mc.score = -1;
for (piece in mainWindow_mc) {
mainWindow_mc[piece].removeMovieClip();
}
_local1.currentPiece = null;
_local1.currentPiece_row = 0;
_local1.currentPiece_col = 4;
stage_mc.pauseSign_mc.removeMovieClip();
_local1.stage_array = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
}
};
stage_mc.onEnterFrame = function () {
if (_global.runGame) {
checkStage();
drawPiece();
}
};
Symbol 43 MovieClip [gameOverWindow] Frame 1
function order(a, b) {
if (Number(a.score) < Number(b.score)) {
return(-1);
}
if (Number(a.score) > Number(b.score)) {
return(1);
}
return(0);
}
gameOver_mc = this;
depth = 0;
dataSender = new LoadVars();
dataReceiver = new LoadVars();
dataReceiver.onLoad = function () {
var _local1 = this;
gameOver_mc.gotoAndStop("loaded");
gameOver_mc.highScores_array = new Array();
gameOver_mc.highScores_array.push({name:_local1.name1, score:_local1.score1});
gameOver_mc.highScores_array.push({name:_local1.name2, score:_local1.score2});
gameOver_mc.highScores_array.push({name:_local1.name3, score:_local1.score3});
gameOver_mc.highScores_array.push({name:_local1.name4, score:_local1.score4});
gameOver_mc.highScores_array.push({name:_local1.name5, score:_local1.score5});
gameOver_mc.highScores_array.push({name:"enter your name", score:_global.score});
gameOver_mc.highScores_array.sort(order);
if (gameOver_mc.highScores_array[0].name != "enter your name") {
gameOver_mc.desc = "Congratulations! You have reached a high score!";
gameOver_mc.attachMovie("newName", "inName_mc", depth++);
gameOver_mc.inName_mc._x = 45;
gameOver_mc.inName_mc._y = 145;
gameOver_mc.inName_mc.inName = "enter your name";
Selection.setFocus("gameOver_mc.inName_mc.inName_txt");
} else {
gameOver_mc.desc = "Good try, but you did not get a high score.";
gameOver_mc.gotoAndStop("lowScore");
}
};
dataSender.cacheKiller = new Date().getTime();
dataSender.action = "getScores";
dataSender.sendAndLoad(_global.highScoresScript, dataReceiver, "GET");
gameOver_mc.gotoAndStop("loading");
Symbol 43 MovieClip [gameOverWindow] Frame 5
dataSender = new LoadVars();
dataReceiver = new LoadVars();
dataReceiver.onLoad = function () {
_global.windowUp = false;
gameOver_mc.removeMovieClip();
};
gameOver_mc.save_btn.onRelease = function () {
counter = 1;
while (counter <= 5) {
if (gameOver_mc.highScores_array[counter].name == "enter your name") {
if (gameOver_mc.inName_mc.inName == "enter your name") {
gameOver_mc.highScores_array[counter].name = "Anonymous";
} else {
gameOver_mc.highScores_array[counter].name = gameOver_mc.inName_mc.inName;
}
}
counter++;
}
dataSender.cacheKiller = new Date().getTime();
dataSender.action = "saveScores";
dataSender.name1 = gameOver_mc.highScores_array[5].name;
dataSender.name2 = gameOver_mc.highScores_array[4].name;
dataSender.name3 = gameOver_mc.highScores_array[3].name;
dataSender.name4 = gameOver_mc.highScores_array[2].name;
dataSender.name5 = gameOver_mc.highScores_array[1].name;
dataSender.score1 = gameOver_mc.highScores_array[5].score;
dataSender.score2 = gameOver_mc.highScores_array[4].score;
dataSender.score3 = gameOver_mc.highScores_array[3].score;
dataSender.score4 = gameOver_mc.highScores_array[2].score;
dataSender.score5 = gameOver_mc.highScores_array[1].score;
dataSender.sendAndLoad(_global.highScoresScript, dataReceiver, "GET");
gameOver_mc.gotoAndStop("saving");
};
stop();
Symbol 43 MovieClip [gameOverWindow] Frame 15
gameOver_mc.close_btn.onRelease = function () {
_global.windowUp = false;
gameOver_mc.removeMovieClip();
};
Symbol 56 MovieClip [highScoresWindow] Frame 1
highScores_mc = this;
highScores_mc.close_btn.onRelease = function () {
_global.windowUp = false;
highScores_mc.removeMovieClip();
};
dataSender = new LoadVars();
dataReceiver = new LoadVars();
dataReceiver.onLoad = function () {
var _local1 = this;
highScores_mc.gotoAndStop("loaded");
highScores_mc.name1 = _local1.name1;
highScores_mc.name2 = _local1.name2;
highScores_mc.name3 = _local1.name3;
highScores_mc.name4 = _local1.name4;
highScores_mc.name5 = _local1.name5;
highScores_mc.score1 = _local1.score1;
highScores_mc.score2 = _local1.score2;
highScores_mc.score3 = _local1.score3;
highScores_mc.score4 = _local1.score4;
highScores_mc.score5 = _local1.score5;
};
dataSender.cacheKiller = new Date().getTime();
dataSender.action = "getScores";
dataSender.sendAndLoad(_global.highScoresScript, dataReceiver, "GET");
highScores_mc.gotoAndStop("loading");
Symbol 141 Button
on (release) {
getURL ("http://www.emeraldtokyo.com");
}