Frame 1
stop();
Stage.showMenu = false;
this.onEnterFrame = function () {
sofar = this.getBytesLoaded();
total = this.getBytesTotal();
pc_txt.text = int((sofar / total) * 100) + "%";
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);
};
game_so = SharedObject.getLocal("neaveInvaders");
score = 0;
gameOver = true;
rnd = Math.random;
play_btn.onRelease = function () {
play();
};
neave_btn.onRelease = function () {
getURL ("http://www.freevideogamesonline.org", "_blank");
};
Key.removeListener(keyListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
if (gameOver_mc._visible) {
return(undefined);
}
if (Key.isDown(83)) {
if (_xscale == 100) {
_yscale = 50;
_xscale = 50;
_x = 125;
_y = 100;
} else {
_yscale = 100;
_xscale = 100;
_y = 0;
_x = 0;
}
}
if (gameOver) {
return(undefined);
}
if (Key.isDown(80)) {
if (quitGame_mc._visible) {
return(undefined);
}
paused = !paused;
if (paused) {
pause_mc.play();
var n = 4;
while (n > 0) {
_root[("fire" + n) + "_mc"].stop();
n--;
}
} else {
pause_mc.stop();
var n = 4;
while (n > 0) {
_root[("fire" + n) + "_mc"].play();
n--;
}
}
pause_mc._visible = paused;
alien_mc._alpha = (paused ? 15 : 100);
if (ufo_mc._visible) {
ufoSound_mc.gotoAndStop(Number(!paused) + 1);
}
}
if (Key.isDown(81)) {
var n = 4;
while (n > 0) {
_root[("fire" + n) + "_mc"].stop();
n--;
}
pause_mc.stop();
pause_mc._visible = false;
quitGame_mc._visible = (paused = true);
alien_mc._alpha = 15;
ufoSound_mc.gotoAndStop(1);
}
if (!quitGame_mc._visible) {
return(undefined);
}
if (Key.isDown(78)) {
quitGame_mc._visible = (paused = false);
alien_mc._alpha = 100;
if (ufo_mc._visible) {
ufoSound_mc.gotoAndStop(2);
}
var n = 4;
while (n > 0) {
_root[("fire" + n) + "_mc"].play();
n--;
}
}
if (Key.isDown(89)) {
gotoAndStop (2);
}
};
Key.addListener(keyListener);
Frame 4
setLives = function () {
var i = 8;
while (i > 0) {
_root[("life" + i) + "_mc"]._visible = lives >= i;
i--;
}
};
setScore = function () {
score_txt.text = String(score).addCommas();
};
resetLaser = function () {
laser_mc._visible = false;
laser_mc._y = laser_mc.yPos;
};
makeAlien = function (i) {
alien_mc.createEmptyMovieClip(i, i);
alien_mc[i]._y = ((i * 30) + playTop) + 1;
var n = Math.ceil((i / 2) + 1);
switch (n) {
case 1 :
var val = 40;
break;
case 2 :
var val = 20;
break;
default :
var val = 10;
}
var j = 0;
while (j < 11) {
alien_mc[i].attachMovie("alien" + n, j, j, {_x:((j * 30) + playMin) + 83, val:val});
j++;
}
};
laser_mc.onEnterFrame = function () {
if (paused) {
return(undefined);
}
if (this._visible) {
if (this._y < 50) {
this._visible = false;
}
this._y = this._y - 12;
}
};
base_mc.onEnterFrame = function () {
if (((paused || (newLife)) || (gameOver)) || (this._currentframe > 1)) {
return(undefined);
}
if (Key.isDown(39) && (this._x < 480)) {
this._x = this._x + 6;
} else if (Key.isDown(37) && (this._x > 20)) {
this._x = this._x - 6;
}
if (Key.isDown(32) && (!laser_mc._visible)) {
fireSound_mc.play();
laser_mc._x = this._x;
laser_mc._y = laser_mc.yPos;
laser_mc._visible = true;
}
};
fire1_mc._visible = (fire2_mc._visible = (fire3_mc._visible = (fire4_mc._visible = false)));
laser_mc.yPos = laser_mc._y;
laser_mc._visible = false;
quitGame_mc._visible = false;
pause_mc._visible = false;
pause_mc.stop();
moveDown = false;
downSpeed = 14;
lives = 3;
setLives();
score = 0;
setScore();
playMax = 480;
playMin = 20;
playTop = 64;
playBtm = 64 + (downSpeed * 8);
Frame 10
i = 5;
this.onEnterFrame = function () {
i--;
makeAlien(i);
if (!i) {
delete this.onEnterFrame;
}
};
ufo_mc.dir = 1;
ufo_mc.onEnterFrame = function () {
if (paused || (newLife)) {
return(undefined);
}
if (this._visible) {
if (this._currentframe == 1) {
if ((this._x > 550) || (this._x < -50)) {
this._visible = false;
ufoSound_mc.gotoAndStop(1);
}
this._x = this._x + (this.dir * 3);
}
} else if ((rnd() < 0.002) && (alien_mc[1]._y > 108)) {
this.dir = (int(rnd() * 2) * 2) - 1;
this._x = 250 - (this.dir * 300);
this._visible = true;
ufoSound_mc.gotoAndStop(2);
}
};
Frame 24
stop();
dir = 4;
dead = (time = (tonePos = 0));
paused = (gameOver = (newLife = false));
if (playTop < playBtm) {
playTop = playTop + downSpeed;
}
speed = (playTop + 120) * 2;
this.onEnterFrame = function () {
if (paused || (newLife)) {
return(undefined);
}
for (var i in alien_mc) {
for (var j in alien_mc[i]) {
var a_mc = alien_mc[i][j];
if ((typeof(a_mc) == "movieclip") && (a_mc.hitTest(laser_mc))) {
explode_mc._x = Number(a_mc._x) + Number(a_mc._parent._x);
explode_mc._y = Number(a_mc._y) + Number(a_mc._parent._y);
explode_mc.gotoAndPlay(2);
score = score + a_mc.val;
setScore();
dead++;
a_mc.removeMovieClip();
resetLaser();
break;
}
}
}
if (laser_mc._visible) {
for (var i in barracks_mc) {
var b_mc = barracks_mc[i];
if (b_mc._visible) {
if (b_mc.hitTest(laser_mc)) {
if (b_mc._currentframe == 4) {
b_mc._visible = false;
} else {
b_mc.nextFrame();
}
resetLaser();
break;
}
}
}
}
if (ufo_mc._visible && (ufo_mc._currentframe == 1)) {
if (ufo_mc.hitTest(laser_mc)) {
ufoSound_mc.gotoAndStop(1);
ufo_mc.gotoAndPlay(2);
resetLaser();
}
}
rate = (1000 - speed) - (dead * 4);
if (rate < 0) {
rate = 0;
}
var n = 4;
while (n > 0) {
var f_mc = _root[("fire" + n) + "_mc"];
if (f_mc._visible) {
with (f_mc) {
if (n < 4) {
_y = _y + 6;
}
if (_y > 390) {
_visible = false;
}
}
if (f_mc._y > 275) {
for (var i in barracks_mc) {
var b_mc = barracks_mc[i];
if (b_mc._visible) {
if (b_mc.hitTest(f_mc)) {
f_mc._visible = false;
if (b_mc._currentframe == 4) {
b_mc._visible = false;
} else {
b_mc.nextFrame();
}
break;
}
}
}
if (base_mc.hitTest(f_mc)) {
f_mc._visible = (laser_mc._visible = (ufo_mc._visible = false));
fire1_mc._visible = (fire2_mc._visible = (fire3_mc._visible = (fire4_mc._visible = false)));
resetLaser();
ufo_mc.gotoAndStop(1);
ufoSound_mc.gotoAndStop(1);
base_mc.gotoAndPlay(2);
newLife = true;
lives--;
if (lives < 1) {
gameOver = true;
gotoAndStop (25);
delete this.onEnterFrame;
return(undefined);
}
}
}
}
if (((rate + 8) * rnd()) < 4) {
var j = int(rnd() * 11);
for (var i in alien_mc) {
var a_mc = alien_mc[i][j];
if (((typeof(a_mc) == "movieclip") && (a_mc._visible)) && (!f_mc._visible)) {
f_mc._x = Number(a_mc._x) + Number(a_mc._parent._x);
f_mc._y = (Number(a_mc._y) + Number(a_mc._parent._y)) + 16;
f_mc._visible = true;
f_mc.gotoAndPlay(2);
break;
}
}
}
n--;
}
if ((getTimer() - time) < rate) {
return(undefined);
}
time = getTimer();
alienSound_mc.gotoAndStop(tonePos + 2);
tonePos++;
tonePos = tonePos % 4;
xMax = playMin;
xMin = playMax;
allGone = true;
for (var i in alien_mc) {
if (moveDown) {
alien_mc[i]._y = alien_mc[i]._y + downSpeed;
} else {
alien_mc[i]._x = alien_mc[i]._x + dir;
}
for (var j in alien_mc[i]) {
if (typeof(alien_mc[i][j]) != "movieclip") {
continue;
}
allGone = false;
alien_mc[i][j].nextFrame();
var x = (Number(alien_mc[i]._x) + Number(alien_mc[i][j]._x));
if (x < xMin) {
xMin = x;
}
if (x > xMax) {
xMax = x;
}
if (moveDown) {
if ((Number(alien_mc[i]._y) + Number(alien_mc[i][j]._y)) > 320) {
lives = 0;
newLife = (gameOver = true);
ufoSound_mc.gotoAndStop(1);
base_mc.gotoAndPlay(2);
gotoAndStop (25);
delete this.onEnterFrame;
return(undefined);
}
}
}
}
if ((!moveDown) && ((xMax > playMax) || (xMin < playMin))) {
dir = dir * -1;
speed = speed + 30;
moveDown = true;
} else {
moveDown = false;
}
if (allGone) {
score = score + 1000;
setScore();
if (lives < 9) {
lives++;
setLives();
}
ufoSound_mc.gotoAndStop(1);
gotoAndPlay (5);
delete this.onEnterFrame;
}
};
Frame 26
stop();
showScores = function () {
var i = 10;
while (i > 0) {
var n = scoreboard_lv["name" + (page + i)];
var s = scoreboard_lv["score" + (page + i)];
var l_mc = this[("line" + i) + "_mc"];
l_mc.rank_txt.text = (page + i) + ".";
l_mc.name_txt.text = (n.length ? (n.toUpperCase()) : "-");
l_mc.score_txt.text = (s.length ? (s.addCommas()) : "-");
l_mc.rank_txt.textColor = (l_mc.name_txt.textColor = (l_mc.score_txt.textColor = ((game_so.data.playerName.length && (n.toUpperCase() == game_so.data.playerName.toUpperCase())) ? 3407616 : 16777215)));
l_mc._visible = true;
loading_mc._visible = false;
i--;
}
};
page = 0;
maxScore = 100;
scoreboard_lv = new LoadVars();
if ((score > 0) && (game_so.data.playerName.length > 0)) {
scoreboard_lv.score = score;
scoreboard_lv.name = game_so.data.playerName.toLowerCase();
}
scoreboard_lv.game = "invaders";
scoreboard_lv.sendAndLoad("http://www.neave.com/games/games_score_text.php", scoreboard_lv, "POST");
scoreboard_lv.onLoad = function (success) {
if (success) {
if (Boolean(scoreboard_lv.success)) {
next_btn._visible = true;
if (scoreboard_lv.maxScore.length > 0) {
maxScore = Number(scoreboard_lv.maxScore);
}
showScores();
} else {
loading_mc.errorMsg = scoreboard_lv.errorMsg.toUpperCase();
loading_mc.gotoAndStop(2);
}
} else {
loading_mc.errorMsg = "COULD NOT ACCESS SCORES.";
loading_mc.gotoAndStop(2);
}
};
score = 0;
next_btn._visible = (last_btn._visible = false);
last_btn.onPress = function () {
page = page - 10;
if (page < 0) {
page = 0;
}
if (page < 10) {
last_btn._visible = false;
}
next_btn._visible = true;
showScores();
};
next_btn.onPress = function () {
page = page + 10;
if (page > maxScore) {
page = maxScore;
}
if (page > (maxScore - 20)) {
next_btn._visible = false;
}
last_btn._visible = true;
showScores();
};
newGame_btn.onRelease = function () {
gotoAndStop (2);
};
ufo_mc.dir = 1;
ufo_mc.onEnterFrame = function () {
if (!this._visible) {
this.dir = (int(rnd() * 2) * 2) - 1;
this._x = 250 - (this.dir * 300);
this._visible = true;
}
this._x = this._x + (this.dir * 3);
if ((this._x > 550) || (this._x < -50)) {
this._visible = false;
}
};
Symbol 4 MovieClip [alien1] Frame 1
stop();
Symbol 4 MovieClip [alien1] Frame 3
gotoAndStop (1);
Symbol 8 MovieClip [alien2] Frame 1
stop();
Symbol 8 MovieClip [alien2] Frame 3
gotoAndStop (1);
Symbol 12 MovieClip [alien3] Frame 1
stop();
Symbol 12 MovieClip [alien3] Frame 3
gotoAndStop (1);
Symbol 22 MovieClip Frame 63
stop();
Symbol 44 MovieClip Frame 1
stop();
Symbol 44 MovieClip Frame 2
_root.setLives();
Symbol 44 MovieClip Frame 26
if (_root.gameOver) {
stop();
}
Symbol 44 MovieClip Frame 36
_x = 85;
Symbol 44 MovieClip Frame 45
_root.newLife = false;
Symbol 48 MovieClip Frame 1
stop();
Symbol 53 MovieClip Frame 1
stop();
Symbol 58 MovieClip Frame 1
stop();
Symbol 61 MovieClip Frame 1
stop();
Symbol 61 MovieClip Frame 14
if (_visible) {
gotoAndPlay (2);
}
Symbol 62 MovieClip Frame 1
stop();
Symbol 62 MovieClip Frame 2
play();
Symbol 62 MovieClip Frame 6
if (_visible) {
if (_root.paused) {
gotoAndPlay (5);
} else {
_y = (_y + 32);
gotoAndPlay (2);
}
} else {
gotoAndStop (1);
}
Symbol 65 MovieClip Frame 1
stop();
Symbol 70 MovieClip Frame 1
stop();
Symbol 72 MovieClip Frame 1
stop();
Symbol 74 MovieClip Frame 1
stop();
Symbol 77 MovieClip Frame 1
stop();
_visible = false;
Symbol 77 MovieClip Frame 2
ufoScore = (int(Math.random() * 6) * 50) + 50;
_root.score = _root.score + ufoScore;
_root.setScore();
Symbol 79 MovieClip Frame 33
stop();
name_txt.restrict = "A-Z 0-9.:\\-";
name_txt.text = _root.game_so.data.playerName;
Selection.setFocus(name_txt);
Selection.setSelection(name_txt.length, name_txt.length);
ok_btn.onRelease = function () {
if (name_txt.length > 0) {
_root.game_so.data.playerName = name_txt.text;
}
_root.nextFrame();
};
ok_btn.onKeyDown = function () {
if (Key.getCode() == 13) {
Key.removeListener(ok_btn);
this.onRelease();
}
};
Key.addListener(ok_btn);
Symbol 81 Button
on (release) {
gotoAndPlay (3);
}