Frame 1
function playFullScreen() {
getURL ("javascript:playFullScreen();void(0);");
quitGame();
}
function menuHandler(o, item) {
item.customItems[1].caption = (paused ? "Unpause game" : "Pause game");
item.customItems[3].caption = (muted ? "Unmute sound" : "Mute sound");
item.customItems[4].caption = (music ? "Stop theme tune" : "Play theme tune");
item.customItems[5].caption = (fastKey ? "Use slower keys" : "Use faster keys");
}
function quitGame() {
lastMusicPlaying = (paused ? (musicOld) : (music));
if (music) {
toggleMusic();
}
stopFall();
if (!quitGame_mc._visible) {
game_so.data.music = lastMusicPlaying;
}
gotoAndStop (2);
}
function pauseGame() {
if (gameOver || (quitGame_mc._visible)) {
return(undefined);
}
sound_mc.gotoAndPlay("popMed");
b_mc._visible = (next_mc._visible = !((paused_mc._visible = (paused = !paused))));
if (paused && (music)) {
musicOld = true;
paused = false;
toggleMusic();
paused = true;
}
if ((!paused) && (musicOld)) {
musicOld = false;
toggleMusic();
}
if (paused) {
trackGamePause();
}
}
function muteSound() {
muted = !muted;
if (muted) {
mute_mc.gotoAndStop(2);
mute_sound.setVolume(0);
} else {
mute_mc.gotoAndStop(1);
mute_sound.setVolume(100);
}
}
function toggleFastKey() {
sound_mc.gotoAndPlay("popMed");
game_so.data.fastKey = (fastKey = !fastKey);
}
function toggleMusic() {
if ((paused || (gameOver)) || (quitGame_mc._visible)) {
return(undefined);
}
if (!lastMusicPlaying) {
sound_mc.gotoAndPlay("popMed");
}
if (_level1 == undefined) {
music = true;
loadMovieNum (g_domain + "nblox_music.swf", 1);
} else {
music = !music;
if (music) {
_level1.playMusic();
} else {
_level1.stopMusic();
}
}
if (paused) {
game_so.data.music = musicOld;
} else {
game_so.data.music = music;
}
}
function loadGameStarts() {
gameStarts = 0;
if (game_so.data.gameStarts != undefined) {
tmpArray = game_so.data.gameStarts.split(":");
if (tmpArray[0] == _root.flashGuestId) {
gameStarts = int(tmpArray[1]);
} else {
gameStarts = 0;
}
}
return(gameStarts);
}
function saveShowVideoAd(inShowVideoAd) {
game_so.data.showVideoAd = _root.showVideoAd;
game_so.flush();
}
function saveGameStarts(inGameStarts) {
game_so.data.gameStarts = (_root.flashGuestId + ":") + inGameStarts;
game_so.flush();
}
stop();
startLevel = 1;
muted = (music = (musicOld = false));
gamesOffset = 0;
g_domain = _root._url;
g_domain = g_domain.substring(0, g_domain.lastIndexOf("/")) + "/";
_root.flashVarNeave = (_root.flashVarNeave == "true") || (_root.flashVarNeave == true);
_root.flashVarTracking = (_root.flashVarTracking == "true") || (_root.flashVarTracking == true);
fsAble = (fsAble == "true") || (fsAble == true);
if (_root.flashVarAd == undefined) {
_root.flashVarAd = g_domain + "nblox_game_over.swf";
}
if (_root.flashGamesPerVideo == undefined) {
_root.flashGamesPerVideo = 0;
}
if (_root.flashGuestId == undefined) {
_root.flashGuestId = 0;
}
_root.flashVarNeave = false;
fsAble = false;
_focusrect = false;
game_so = SharedObject.getLocal("neaveNBlox");
if (game_so.data.fastKey === undefined) {
game_so.data.fastKey = false;
}
if (game_so.data.music === undefined) {
game_so.data.music = false;
}
if (game_so.data.showVideoAd === undefined) {
game_so.data.showVideoAd = false;
}
lastMusicPlaying = game_so.data.music == true;
fastKey = game_so.data.fastKey == true;
showVideoAd = game_so.data.showVideoAd == true;
gameStarts = loadGameStarts();
if (showVideoAd) {
gamesOffset = 1;
}
this.onEnterFrame = function () {
sofar = this.getBytesLoaded();
total = this.getBytesTotal();
if (sofar == total) {
delete this.onEnterFrame;
nextFrame();
}
};
Stage.showMenu = true;
fs_cm = new ContextMenu(menuHandler);
fs_cm.hideBuiltInItems();
fs_cm.customItems.push(new ContextMenuItem("Start game in full screen", playFullScreen, false, true, fsAble), new ContextMenuItem("Pause game", pauseGame, false, true, false), new ContextMenuItem("Quit game", quitGame, false, true, false), new ContextMenuItem("Mute sound", muteSound, false, true, false), new ContextMenuItem("Play theme tune", toggleMusic, false, true, false), new ContextMenuItem("Use faster keys", toggleFastKey, false, true, false));
_root.menu = fs_cm;
Frame 2
function linkTF() {
getURL ("http://www.tetrisfriends.com/", "_blank");
}
function linkNeave() {
trace("linkNeave");
if (!fsAble) {
getURL ("http://www.neave.com/games/nblox/", "_blank");
}
getURL ("javascript:quitGame();void(0);");
}
function startVideoAd() {
_root.showVideoAd = false;
_root.saveShowVideoAd(_root.showVideoAd);
getURL ("javascript:js_videoStart();");
}
function trackGameEvent(inCategory, inAction, inLabel) {
if (_root.flashVarTracking) {
getURL (((((("javascript:js_analyticsTrackEvent('" + inCategory) + "', '") + inAction) + "', '") + inLabel) + "');void(0);");
}
}
function trackGameStart() {
_root.gameStarts = int(_root.gameStarts) + 1;
_root.showVideoAd = (_root.flashGamesPerVideo != 0) && (_root.showVideoAd || (((_root.gameStarts + gamesOffset) % _root.flashGamesPerVideo) == 0));
_root.saveShowVideoAd(_root.showVideoAd);
_root.saveGameStarts(_root.gameStarts);
trackGameEvent("Game", "Start", "N-Blox - Game " + _root.gameStarts);
}
function trackGameFinish() {
trackGameEvent("Game", "Finish", "N-Blox");
if (_root.showVideoAd) {
startVideoAd();
}
}
function trackGameRestart() {
trackGameEvent("Game", "Restart", "N-Blox");
getURL ("javascript:window.location.reload();");
}
function trackGamePause() {
trackGameEvent("Game", "Pause", "N-Blox");
}
function checkButtons() {
up_btn._alpha = (down_btn._alpha = 100);
up_btn.enabled = (down_btn.enabled = true);
if (startLevel < 2) {
startLevel = 1;
down_btn._alpha = 50;
down_btn.enabled = false;
} else if (startLevel > 9) {
startLevel = 10;
up_btn._alpha = 50;
up_btn.enabled = false;
}
}
stop();
url_txt.text = g_domain;
var today = new Date();
var year = today.getFullYear();
text_legal.text = (" \u00A9 2003-" + year) + " Tetris Holding. Tetris N-Blox developed by Paul Neave.\nTetris\u00AE, N-Blox\u2122 & the Tetris trade dress are owned by Tetris Holding.";
String.prototype.addCommas = function () {
var _local4 = this.length;
var _local3 = "";
var _local2 = 0;
while (_local2 <= _local4) {
_local3 = this.charAt(_local4 - _local2) + _local3;
if ((((_local2 % 3) == 0) && (_local2 > 0)) && (_local2 < _local4)) {
_local3 = "," + _local3;
}
_local2++;
}
return(_local3);
};
String.prototype.stripSpaces = function () {
if (this.length == 0) {
return("");
}
this=this.split(".").join("");//parameter overwritten
this.split(".").join("");
this=this.split("-").join("");//parameter overwritten
this.split("-").join("");
while (this.charAt(0) == " ") {
this=this.substr(1);//parameter overwritten
this.substr(1);
}
this=this.split(" ").join(" ");//parameter overwritten
this.split(" ").join(" ");
this=this.split(" ").join(" ");//parameter overwritten
this.split(" ").join(" ");
return(this);
};
if (_root.flashVarNeave) {
quit_btn._visible = true;
quit_btn.onRelease = linkNeave;
} else {
quit_btn._visible = false;
quit_btn.onRelease = null;
}
score = 0;
level = startLevel;
play_btn.onRelease = function () {
play();
};
_root.menu.customItems[1].visible = (_root.menu.customItems[2].visible = (_root.menu.customItems[3].visible = (_root.menu.customItems[4].visible = (_root.menu.customItems[5].visible = false))));
checkButtons();
down_btn.onRelease = function () {
startLevel--;
checkButtons();
};
up_btn.onRelease = function () {
startLevel++;
checkButtons();
};
ok_btn.onRelease = function () {
play();
trackGameStart();
};
ok_btn.onKeyDown = function () {
var _local2 = Key.getCode();
if (_local2 == 13) {
Key.removeListener(ok_btn);
this.onRelease();
}
if (_local2 == 187) {
up_btn.onRelease();
}
if (_local2 == 189) {
down_btn.onRelease();
}
if ((_local2 > 47) && (_local2 < 58)) {
startLevel = _local2 - 48;
if (startLevel == 0) {
startLevel = 10;
}
checkButtons();
}
};
Key.addListener(ok_btn);
Frame 3
function startFall() {
timeout = setInterval(down, speed);
}
function stopFall() {
clearInterval(keyMoverID);
clearInterval(timeout);
}
function drawBlock(num, blockPos) {
b_mc[blockPos].gotoAndStop(num + 1);
}
function drawNextBlock(num, blockPos) {
next_mc[blockPos].gotoAndStop(num + 1);
}
function drawThisShape() {
if (moved) {
var _local1 = 0;
while (_local1 < 4) {
drawBlock(0, block_array[_local1]);
_local1++;
}
} else {
moved = true;
}
var _local1 = 0;
while (_local1 < 4) {
blockPos = shape_array[((thisShape * 16) + (rotation * 4)) + _local1];
block_array[_local1] = ((((blockPos >> 2) * 6) + blockPos) + xPos) + yPos;
drawBlock(thisShape + 1, block_array[_local1]);
_local1++;
}
}
function newBag() {
bagNum = 0;
bag_array = new Array(0, 1, 2, 3, 4, 5, 6, int(Math.random() * 7));
bag_array.sort(shuffle);
}
function drawNextShape() {
bagNum++;
if (bagNum == 8) {
newBag();
}
nextShape = bag_array[bagNum];
var _local1 = 0;
while (_local1 < 11) {
drawNextBlock(0, _local1);
_local1++;
}
_local1 = 0;
while (_local1 < 4) {
drawNextBlock(nextShape + 1, shape_array[(nextShape * 16) + _local1]);
_local1++;
}
}
function collision(x, y, rot) {
var _local2 = 0;
while (_local2 < 4) {
blockPos = shape_array[((thisShape * 16) + (rot * 4)) + _local2];
var _local1 = ((((blockPos >> 2) * 6) + blockPos) + x) + y;
if (_local1 < 0) {
_local1 = 0;
}
if (flag_array[_local1] != 0) {
return(true);
}
_local2++;
}
return(false);
}
function left() {
var _local2 = 0;
while (_local2 < 4) {
var _local1 = block_array[_local2] - yPos;
while (_local1 >= 0) {
if (_local1 == 0) {
return(undefined);
}
_local1 = _local1 - 10;
}
_local2++;
}
if (!collision(xPos - 1, yPos, rotation)) {
xPos--;
drawThisShape();
}
updateAfterEvent();
}
function right() {
var _local2 = 0;
while (_local2 < 4) {
var _local1 = block_array[_local2] - yPos;
while (_local1 >= 0) {
if (_local1 == 9) {
return(undefined);
}
_local1 = _local1 - 10;
}
_local2++;
}
if (!collision(xPos + 1, yPos, rotation)) {
xPos++;
drawThisShape();
}
updateAfterEvent();
}
function rotate(clockwise) {
testRot = rotation;
if (clockwise) {
testRot++;
} else {
testRot--;
}
if (testRot == 4) {
testRot = 0;
} else if (testRot == -1) {
testRot = 3;
}
var _local2 = 0;
while (_local2 < 4) {
blockPos = shape_array[((thisShape * 16) + (testRot * 4)) + _local2];
var _local1 = (((blockPos >> 2) * 6) + blockPos) + xPos;
while (_local1 >= -1) {
if (((_local1 == -1) && (xPos < 0)) || ((_local1 == 0) && (xPos > 6))) {
return(undefined);
}
_local1 = _local1 - 10;
}
_local2++;
}
if ((((((blockPos >> 2) * 6) + blockPos) + xPos) + yPos) > 179) {
return(undefined);
}
if (!collision(xPos, yPos, testRot)) {
rotation = testRot;
drawThisShape();
sound_mc.gotoAndPlay("popHi");
}
}
function down() {
if ((gameOver || (paused)) || (simult)) {
return(undefined);
}
score++;
if (((block_array[3] - xPos) < 170) && (!collision(xPos, yPos + 10, rotation))) {
yPos = yPos + 10;
drawThisShape();
} else {
hitFloor = true;
var _local1 = 0;
while (_local1 < 4) {
flag_array[block_array[_local1]] = thisShape + 1;
_local1++;
}
simult = 0;
var _local2 = 0;
while (_local2 < 180) {
var _local3 = 0;
while (_local3 < 10) {
if (flag_array[_local3 + _local2] == 0) {
break;
}
if (_local3 == 9) {
stopFall();
_local1 = 0;
while (_local1 < 10) {
b_mc[_local1 + _local2].bang_mc.y = _local2;
b_mc[_local1 + _local2].bang_mc.play();
_local1++;
}
simult++;
lines++;
}
_local3++;
}
_local2 = _local2 + 10;
}
if (simult > 0) {
sound_mc.gotoAndPlay("win");
switch (simult) {
case 1 :
score = score + (level * 40);
break;
case 2 :
score = score + (level * 100);
break;
case 3 :
score = score + (level * 300);
break;
case 4 :
score = score + (level * 1200);
}
}
scoreTxt = String(score).addCommas();
level = int(lines / 10) + startLevel;
speed = ((level < 10) ? (600 - (level * 50)) : 100);
xPos = 3;
yPos = -10;
rotation = 0;
moved = false;
thisShape = nextShape;
if (!simult) {
drawNextShape();
drawThisShape();
sound_mc.gotoAndPlay("popLo");
}
if (((simult == 0) && (collision(xPos, yPos, rotation))) && (yPos == -10)) {
if (music) {
lastMusicPlaying = true;
toggleMusic();
}
gameOver = true;
stopFall();
paused_mc._visible = (unpause_btn._visible = (pause_btn._visible = (pauseHelp_btn._visible = false)));
sound_mc.gotoAndPlay("end");
quitGame_mc.gotoAndStop(2);
quitGame_mc._visible = true;
}
}
updateAfterEvent();
}
function fastDrop() {
hitFloor = false;
sound_mc.gotoAndPlay("drop");
while (!hitFloor) {
down();
}
}
function shuffle() {
return(Math.floor(Math.random() * 2));
}
newBag();
this.onKeyDown = function () {
if (gameOver || (simult)) {
return(undefined);
}
var _local2 = Key.getCode();
switch (_local2) {
case 80 :
pauseGame();
break;
case 81 :
quit_btn.onRelease();
break;
case 77 :
muteSound();
}
if (!paused) {
switch (_local2) {
case 84 :
toggleMusic();
break;
case 75 :
toggleFastKey();
break;
case 37 :
case 65 :
if (fastKey) {
clearInterval(keyMoverID);
keyMoverID = setInterval(left, 40);
} else {
left();
}
break;
case 39 :
case 68 :
if (fastKey) {
clearInterval(keyMoverID);
keyMoverID = setInterval(right, 40);
} else {
right();
}
break;
case 40 :
case 83 :
this.onEnterFrame = down;
break;
case 32 :
case 17 :
fastDrop();
break;
case 38 :
case 87 :
case 88 :
rotate(true);
break;
case 90 :
case 35 :
case 222 :
rotate(false);
}
}
updateAfterEvent();
};
this.onKeyUp = function () {
clearInterval(keyMoverID);
delete this.onEnterFrame;
};
Key.removeListener(this);
Key.addListener(this);
gameOver = true;
paused = (pausedOld = (moved = (hitFloor = (music = false))));
score = (scoreTxt = (lines = (thisShape = (nextShape = (rotation = 0)))));
level = startLevel;
speed = ((level < 10) ? (600 - (level * 50)) : 100);
xPos = 3;
yPos = -10;
shape_array = new Array(5, 6, 9, 10, 5, 6, 9, 10, 5, 6, 9, 10, 5, 6, 9, 10, 4, 5, 6, 9, 1, 4, 5, 9, 1, 4, 5, 6, 1, 5, 6, 9, 4, 5, 9, 10, 2, 5, 6, 9, 4, 5, 9, 10, 2, 5, 6, 9, 5, 6, 8, 9, 1, 5, 6, 10, 5, 6, 8, 9, 1, 5, 6, 10, 4, 5, 6, 8, 0, 1, 5, 9, 2, 4, 5, 6, 1, 5, 9, 10, 4, 5, 6, 10, 1, 5, 8, 9, 0, 4, 5, 6, 1, 2, 5, 9, 4, 5, 6, 7, 1, 5, 9, 13, 4, 5, 6, 7, 1, 5, 9, 13);
block_array = new Array(0, 0, 0, 0);
flag_array = new Array();
var i = 18;
while (i >= 0) {
var j = 0;
while (j < 10) {
var k = ((i * 10) + j);
b_mc.attachMovie("block", k, k, {_x:j * 20, _y:i * 20});
flag_array[k] = 0;
j++;
}
i--;
}
var i = 0;
while (i < 3) {
var j = 0;
while (j < 4) {
var k = ((i * 4) + j);
next_mc.attachMovie("block", k, k, {_x:j * 20, _y:i * 20});
j++;
}
i++;
}
Frame 11
mute_mc.onRollOver = function () {
mute_color.setRGB(0);
};
mute_mc.onRollOut = (mute_mc.onDragOut = function () {
mute_color.setRGB(7833770);
});
mute_mc.onRelease = muteSound;
mute_color = new Color(mute_mc);
mute_sound = new Sound();
muted = !muted;
mute_mc.onRelease();
Frame 12
paused_mc._visible = false;
paused_mc.stop();
if (_root.flashVarNeave) {
quit_btn._visible = true;
pause_btn._visible = true;
paused_mc.gotoAndStop("paused");
pauseHelp_btn._visible = false;
} else {
quit_btn._visible = false;
pause_btn._visible = false;
paused_mc.gotoAndStop("pausedWithHelp");
pauseHelp_btn._visible = true;
}
Frame 19
stop();
_root.menu.customItems[1].visible = (_root.menu.customItems[2].visible = (_root.menu.customItems[3].visible = (_root.menu.customItems[4].visible = (_root.menu.customItems[5].visible = true))));
unpause_btn.onRelease = (pause_btn.onRelease = (pauseHelp_btn.onRelease = pauseGame));
quit_btn.onRelease = function () {
if (gameOver) {
return(undefined);
}
if (quitGame_mc._visible) {
quitGame_mc.no_btn.onRelease();
return(undefined);
}
stopFall();
sound_mc.gotoAndPlay("popMed");
if (!paused) {
musicOld = music;
if (music) {
toggleMusic();
}
game_so.data.music = musicOld;
}
b_mc._visible = (next_mc._visible = (paused_mc._visible = (unpause_btn._visible = false)));
pausedOld = paused;
quitGame_mc._visible = (paused = true);
};
drawNextShape();
thisShape = nextShape;
drawThisShape();
drawNextShape();
gameOver = false;
stopFall();
startFall();
if (lastMusicPlaying) {
toggleMusic();
}
Symbol 2 MovieClip Frame 1
stop();
Symbol 2 MovieClip Frame 7
x = Number(_parent._name) - y;
with (_root) {
var j = y;
while (j > 0) {
drawBlock((flag_array[x + j] = flag_array[(x + j) - 10]), x + j);
j = j - 10;
}
drawBlock((flag_array[x] = 0), x);
if (!x) {
simult--;
}
if (!simult) {
drawNextShape();
drawThisShape();
startFall();
}
}
Symbol 10 MovieClip [block] Frame 1
stop();
Symbol 29 MovieClip Frame 5
stop();
Symbol 39 MovieClip Frame 1
stop();
Symbol 39 MovieClip Frame 3
stop();
Symbol 39 MovieClip Frame 5
stop();
Symbol 39 MovieClip Frame 7
stop();
Symbol 39 MovieClip Frame 9
stop();
Symbol 39 MovieClip Frame 11
stop();
Symbol 53 MovieClip Frame 1
stop();
Symbol 71 MovieClip Frame 1
stop();
_visible = false;
yes_btn.onRelease = function () {
with (_parent) {
music = musicOld;
quitGame();
}
};
no_btn.onRelease = function () {
_visible = false;
with (_parent) {
paused = pausedOld;
b_mc._visible = (next_mc._visible = !paused);
paused_mc._visible = paused;
unpause_btn._visible = true;
stopFall();
startFall();
sound_mc.gotoAndPlay("popMed");
if ((!paused) && (musicOld)) {
toggleMusic();
}
}
};
yes_btn.onKeyDown = function () {
if (_visible) {
if (Key.getCode() == 89) {
this.onRelease();
}
if (Key.getCode() == 78) {
no_btn.onRelease();
}
}
};
Key.addListener(yes_btn);
Symbol 71 MovieClip Frame 2
_root.menu.customItems[1].visible = (_root.menu.customItems[2].visible = (_root.menu.customItems[3].visible = (_root.menu.customItems[4].visible = (_root.menu.customItems[5].visible = false))));
_root.pause_btn._visible = (_root.quit_btn._visible = false);
Key.removeListener(yes_btn);
endAd_mc.loadMovie(_root.flashVarAd);
again_btn.onRelease = function () {
with (_parent) {
_root.trackGameRestart();
music = musicOld;
quitGame();
}
};
_root.trackGameFinish();
Symbol 101 MovieClip Frame 1
stop();
Symbol 101 MovieClip Frame 2
stop();