Frame 1
stop();
Stage.showMenu = false;
startLevel = 1;
this.onEnterFrame = function () {
sofar = this.getBytesLoaded();
total = this.getBytesTotal();
if (sofar == total) {
delete this.onEnterFrame;
nextFrame();
}
};
Frame 2
String.prototype.addCommas = function () {
var len = this.length;
var str = "";
var i = 0;
while (i <= len) {
str = this.charAt(len - i) + str;
if ((((i % 3) == 0) && (i > 0)) && (i < len)) {
str = "," + str;
}
i++;
}
return(str);
};
so = SharedObject.getLocal("neaveTetris");
if (!playerName.length) {
playerName = so.data.playerName;
}
score = 0;
level = startLevel;
this.onKeyDown = function () {
if (Key.getCode() == 81) {
getURL ("javascript:window.close();");
}
};
Key.addListener(this);
Frame 3
function checkBtns() {
if (startLevel < 2) {
DnBtn._alpha = 50;
DnBtn.enabled = false;
} else if (startLevel > 9) {
UpBtn._alpha = 50;
UpBtn.enabled = false;
} else {
UpBtn._alpha = (DnBtn._alpha = 100);
UpBtn.enabled = (DnBtn.enabled = true);
}
}
stop();
checkBtns();
Frame 4
function startFall() {
timeout = setInterval(down, speed);
}
function stopFall() {
clearInterval(timeout);
}
function drawBlock(num, blockPos) {
B[blockPos].gotoAndStop(num + 1);
}
function drawNextBlock(num, blockPos) {
N[blockPos].gotoAndStop(num + 1);
}
function drawThisShape() {
if (moved) {
var i = 0;
while (i < 4) {
drawBlock(0, block[i]);
i++;
}
} else {
moved = true;
}
var i = 0;
while (i < 4) {
blockPos = shape[((thisShape * 16) + (rotation * 4)) + i];
block[i] = ((((blockPos >> 2) * 6) + blockPos) + xPos) + yPos;
drawBlock(thisShape + 1, block[i]);
i++;
}
}
function drawNextShape() {
nextShape = int(Math.random() * 7);
var i = 0;
while (i < 11) {
drawNextBlock(0, i);
i++;
}
var i = 0;
while (i < 4) {
drawNextBlock(nextShape + 1, shape[(nextShape * 16) + i]);
i++;
}
}
function collision(x, y, rot) {
var i = 0;
while (i < 4) {
blockPos = shape[((thisShape * 16) + (rot * 4)) + i];
if (flag[((((blockPos >> 2) * 6) + blockPos) + x) + y] != 0) {
return(true);
}
i++;
}
return(false);
}
function left() {
var i = 0;
while (i < 4) {
var x = (block[i] - yPos);
while (x >= 0) {
if (x == 0) {
return(undefined);
}
x = x - 10;
}
i++;
}
if (!collision(xPos - 1, yPos, rotation)) {
xPos--;
drawThisShape();
}
}
function right() {
var i = 0;
while (i < 4) {
var x = (block[i] - yPos);
while (x >= 0) {
if (x == 9) {
return(undefined);
}
x = x - 10;
}
i++;
}
if (!collision(xPos + 1, yPos, rotation)) {
xPos++;
drawThisShape();
}
}
function rotate(clockwise) {
testRot = rotation;
if (clockwise) {
testRot++;
} else {
testRot--;
}
if (testRot == 4) {
testRot = 0;
} else if (testRot == -1) {
testRot = 3;
}
var i = 0;
while (i < 4) {
blockPos = shape[((thisShape * 16) + (testRot * 4)) + i];
var x = ((((blockPos >> 2) * 6) + blockPos) + xPos);
while (x >= -1) {
if (((x == -1) && (xPos < 0)) || ((x == 0) && (xPos > 6))) {
return(undefined);
}
x = x - 10;
}
i++;
}
if ((((((blockPos >> 2) * 6) + blockPos) + xPos) + yPos) > 179) {
return(undefined);
}
if (!collision(xPos, yPos, testRot)) {
rotation = testRot;
drawThisShape();
Snd.gotoAndPlay("popHi");
}
}
function down() {
if (gameOver || (simult)) {
return(undefined);
}
score++;
if (((block[3] - xPos) < 170) && (!collision(xPos, yPos + 10, rotation))) {
yPos = yPos + 10;
drawThisShape();
} else {
var i = 0;
while (i < 4) {
flag[block[i]] = thisShape + 1;
i++;
}
simult = 0;
var y = 0;
while (y < 180) {
var x = 0;
while (x < 10) {
if (flag[x + y] == 0) {
break;
}
if (x == 9) {
stopFall();
var i = 0;
while (i < 10) {
B[i + y].Bang.y = y;
B[i + y].Bang.play();
i++;
}
simult++;
lines++;
}
x++;
}
y = y + 10;
}
if (simult) {
Snd.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();
if (collision(xPos, yPos, rotation) && (yPos == -10)) {
gameOver = true;
stopFall();
Snd.gotoAndPlay("end");
Quitter.gotoAndStop(2);
Quitter._visible = true;
} else {
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();
Snd.gotoAndPlay("popLo");
}
}
}
updateAfterEvent();
}
function pause() {
if (gameOver || (Quitter._visible)) {
return(undefined);
}
Snd.gotoAndPlay("popMed");
B._visible = !((Unpause._visible = (paused = !paused)));
if (paused) {
stopFall();
} else {
startFall();
}
}
function quit() {
if (gameOver) {
return(undefined);
}
Snd.gotoAndPlay("popMed");
stopFall();
B._visible = (Unpause._visible = false);
Quitter._visible = (paused = true);
}
this.onKeyDown = function () {
if (gameOver || (simult)) {
return(undefined);
}
var keyCode = Key.getCode();
switch (keyCode) {
case 80 :
pause();
break;
case 81 :
quit();
}
if (!paused) {
switch (keyCode) {
case Key.LEFT :
left();
break;
case Key.RIGHT :
right();
break;
case Key.DOWN :
this.onEnterFrame = down;
break;
case Key.UP :
case 88 :
rotate(true);
break;
case 90 :
rotate(false);
}
}
updateAfterEvent();
};
this.onKeyUp = function () {
delete this.onEnterFrame;
};
Key.addListener(this);
gameOver = true;
paused = (moved = false);
score = (scoreTxt = (lines = (thisShape = (nextShape = (rotation = 0)))));
level = startLevel;
speed = ((level < 10) ? (600 - (level * 50)) : 100);
xPos = 3;
yPos = -10;
shape = 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 = new Array(0, 0, 0, 0);
flag = new Array();
var i = 18;
while (i >= 0) {
var j = 0;
while (j < 10) {
var k = ((i * 10) + j);
B.attachMovie("Block", k, k, {_x:j * 20, _y:i * 20});
flag[k] = 0;
j++;
}
i--;
}
var i = 0;
while (i < 3) {
var j = 0;
while (j < 4) {
var k = ((i * 4) + j);
N.attachMovie("Block", k, k, {_x:j * 20, _y:i * 20});
j++;
}
i++;
}
Instance of Symbol 64 MovieClip "Quitter" in Frame 16
onClipEvent (load) {
_visible = false;
}
Instance of Symbol 67 MovieClip "Unpause" in Frame 16
onClipEvent (load) {
_visible = false;
}
Frame 24
stop();
drawNextShape();
thisShape = nextShape;
drawThisShape();
drawNextShape();
gameOver = false;
startFall();
Frame 25
stop();
Frame 26
function showScores() {
var i = 10;
while (i > 0) {
var n = scoreboard["name" + (page + i)];
var s = scoreboard["score" + (page + i)];
var L = this["Line" + i];
L.RankTxt.text = (page + i) + ".";
L.NameTxt.text = (n.length ? (n.toLowerCase()) : "-");
L.ScoreTxt.text = (s.length ? (s.addCommas()) : "-");
L.RankTxt.textColor = (L.NameTxt.textColor = (L.ScoreTxt.textColor = ((playerName.length && (n.toLowerCase() == playerName.toLowerCase())) ? 16777215 : 7833770)));
L._visible = true;
Loading._visible = false;
i--;
}
}
stop();
page = 0;
maxScore = 100;
BackBtn._visible = (NextBtn._visible = false);
scoreboard = new LoadVars();
if (score) {
scoreboard.score = score;
scoreboard.name = (playerName.length ? (playerName.toLowerCase()) : "");
}
scoreboard.game = "tetris";
scoreboard.sendAndLoad("http://localhost/games/games_score_lite.php", scoreboard, "POST");
scoreboard.onLoad = function (success) {
if (success) {
if (Boolean(scoreboard.success)) {
NextBtn._visible = true;
showScores();
} else {
Loading.errorMsg = scoreboard.errorMsg.toLowerCase();
Loading.gotoAndStop(2);
}
} else {
Loading.errorMsg = "could not load scores.";
Loading.gotoAndStop(2);
}
};
score = 0;
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[x + j] = flag[(x + j) - 10]), x + j);
j = j - 10;
}
if (!x) {
simult--;
}
if (!simult) {
drawNextShape();
drawThisShape();
startFall();
}
}
Symbol 10 MovieClip [Block] Frame 1
stop();
Symbol 11 MovieClip [pnFlashGames] Frame 1
#initclip 1
pnFlashGames = function () {
this.gid = _root.pn_gid;
};
pnFlashGames.prototype.getUserInfo = function () {
};
pnFlashGames.prototype.getUserInfo_Result = function () {
};
pnFlashGames.prototype.storeScore = function (score) {
varsObj = new LoadVars();
varsObj.score = score;
varsObj.func = "storeScore";
varsObj.gid = this.gid;
varsObj.type = "user";
varsObj.module = "pnFlashGames";
varsObj.parent = this;
varsObj.onLoad = this.storeScore_Result;
varsObj.sendAndLoad("index.php", varsObj, "POST");
};
pnFlashGames.prototype.storeScore_Result = function (success) {
if (this.opSuccess == "true") {
}
};
Object.registerClass("pnFlashGames", pnFlashGames);
#endinitclip
Symbol 21 Button
on (press) {
Key.removeListener(this);
play();
}
Symbol 24 Button
on (release) {
getURL ("http://www.neave.com/games/", "_blank");
}
Symbol 27 MovieClip Frame 12
stop();
Symbol 31 Button
on (press) {
play();
}
Symbol 33 Button
on (press) {
startLevel++;
checkBtns();
}
Symbol 34 Button
on (press) {
startLevel--;
checkBtns();
}
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 51 Button
on (press) {
quit();
}
Symbol 53 Button
on (press) {
pause();
}
Symbol 56 Button
on (press, keyPress "y") {
tellTarget ("/") {
stopFall();
};
gotoAndStop (2);
}
Symbol 58 Button
on (press, keyPress "n") {
_visible = false;
_root.pause();
}
Symbol 63 Button
on (press) {
delete scoreboard;
tellTarget ("/") {
gotoAndStop (2);
};
}
Symbol 64 MovieClip Frame 1
stop();
Symbol 64 MovieClip Frame 2
stop();
pnConnector.storeScore(_parent.score);
_root.PauseBtn._visible = (_root.QuitBtn._visible = false);
Instance of Symbol 65 MovieClip "Hit" in Symbol 67 MovieClip Frame 1
on (press) {
_root.pause();
}
Symbol 70 Button
on (press) {
delete scoreboard;
gotoAndStop (2);
}
Symbol 72 Button
on (press) {
page = page - 10;
if (page < 0) {
page = 0;
}
if (page < 10) {
BackBtn._visible = false;
}
NextBtn._visible = true;
showScores();
}
Symbol 74 Button
on (press) {
page = page + 10;
if (page > maxScore) {
page = maxScore;
}
if (page > (maxScore - 20)) {
NextBtn._visible = false;
}
BackBtn._visible = true;
showScores();
}
Symbol 80 MovieClip Frame 1
_visible = false;
Symbol 82 MovieClip Frame 1
stop();
errorMsg = "";