Frame 1
version = "040229";
Frame 2
stop();
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.neave.com/games/", "_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 3
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 9
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 23
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 (24);
delete this.onEnterFrame;
return(undefined);
}
}
}
}
temp = (rate + 8) * rnd();
if (temp < 100) {
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 (24);
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 (4);
delete this.onEnterFrame;
}
};
Symbol 4 MovieClip [alien3] Frame 1
stop();
Symbol 4 MovieClip [alien3] Frame 3
gotoAndStop (1);
Symbol 7 MovieClip [alien2] Frame 1
stop();
Symbol 7 MovieClip [alien2] Frame 3
gotoAndStop (1);
Symbol 11 MovieClip [alien1] Frame 1
stop();
Symbol 11 MovieClip [alien1] Frame 3
gotoAndStop (1);
Symbol 13 Button
on (release) {
getURL (("http://www.neodelight.com?ref=" + _root.game) + "&ref_loc=intro", "_BLANK");
}
Symbol 24 MovieClip Frame 1
startFrame = _parent._currentframe;
Symbol 24 MovieClip Frame 2
vol = (1 - ((_parent._currentFrame - startFrame) / (_parent._totalFrames - startFrame))) * 100;
if (vol < 0) {
vol = 0;
}
_parent.snd.setVolume(vol);
Symbol 24 MovieClip Frame 3
gotoAndPlay (2);
Symbol 25 MovieClip Frame 1
snd = new Sound(this);
snd.setVolume(100);
_parent.stop();
Symbol 25 MovieClip Frame 123
stop();
_parent.play();
Symbol 33 MovieClip Frame 63
stop();
Symbol 38 Button
on (release) {
getURL ("http://www.neodelight.com/highscores?game=spacevaders&ref=spacevaders&ref_loc=highscores&ref_ver=" + _root.version, "_BLANK");
}
Symbol 46 Button
on (release) {
getURL ("http://www.neodelight.com?ref=spacevaders&ref_loc=moregames&ref_ver=" + _root.version, "_BLANK");
}
Symbol 59 MovieClip Frame 1
stop();
Symbol 59 MovieClip Frame 2
_root.setLives();
Symbol 59 MovieClip Frame 26
if (_root.gameOver) {
stop();
}
Symbol 59 MovieClip Frame 36
_x = 85;
Symbol 59 MovieClip Frame 45
_root.newLife = false;
Symbol 64 MovieClip Frame 1
stop();
Symbol 69 MovieClip Frame 1
stop();
Symbol 74 MovieClip Frame 1
stop();
Symbol 79 MovieClip Frame 1
stop();
Symbol 79 MovieClip Frame 14
if (_visible) {
gotoAndPlay (2);
}
Symbol 85 MovieClip Frame 1
stop();
Symbol 85 MovieClip Frame 2
play();
Symbol 85 MovieClip Frame 6
if (_visible) {
if (_root.paused) {
gotoAndPlay (5);
} else {
_y = (_y + 32);
gotoAndPlay (2);
}
} else {
gotoAndStop (1);
}
Symbol 91 MovieClip Frame 1
stop();
Symbol 96 MovieClip Frame 1
stop();
Symbol 98 MovieClip Frame 1
stop();
Symbol 100 MovieClip Frame 1
stop();
Symbol 104 MovieClip Frame 1
#initclip 1
_global.api = new Object();
_global.api.debug = new Object();
_global.api.highscore = new Object();
_global.api.debug.describe = function (o) {
switch (typeof(o)) {
case "movieclip" :
return("/" + o._target);
case "object" :
case "array" :
var d = typeof(o);
var first = true;
for (var i in o) {
if (!first) {
d = d + ", ";
} else {
d = d + "{";
first = false;
}
d = d + ((i + ": ") + _global.api.debug.describe(o[i]));
}
if (!first) {
d = d + "}";
}
return(d);
case "number" :
case "string" :
}
return(o.toString());
};
_global.api.snd = new Object();
_global.api.snd.lib = new Object();
_global.api.snd.load = function (name, url) {
var s = new Sound();
if (url eq "") {
s.attachSound(name);
} else {
s.loadSound(url);
}
_global.api.snd.lib[name] = s;
};
_global.api.snd.play = function (name) {
_root.snd[name].gotoAndPlay(1);
};
_global.api.highscore.initSession = function () {
this.session = "";
while (this.session.length < 20) {
this.session = this.session + this.charTable.charAt(Math.round(Math.random() * (this.charTable.length - 4)));
}
this.charTableIndex = new Array();
var i = 0;
while (i < this.charTable.length) {
this.charTableIndex[this.charTable.charCodeAt(i)] = i;
i++;
}
};
_global.api.highscore.submit = function (pGame, pDisciple, pScore0, pScore1) {
var s = (("g=" + pGame) + "&");
s = s + (("d=" + pDisciple) + "&");
s = s + (("s0=" + pScore0) + "&");
s = s + (("s1=" + pScore1) + "&");
s = s + ("se=" + escape(session));
s = s + "&c=42";
var urlSubmit = ((this.urlSubmit + "?s=") + escape(this.encrypt(this.encrypt(s, this.keystring), this.keystring2)).split("%").join("_"));
trace(urlSubmit);
getURL (urlSubmit, "_blank");
};
_global.api.highscore.encrypt = function (text, pKey) {
var crypt = "";
var checkSum = 0;
var shift;
var code;
var i = 0;
while (i < text.length) {
char = this.charTableIndex[text.charCodeAt(i)];
shift = this.charTableIndex[pKey.charCodeAt(i % pKey.length)];
code = (char + shift) + checkSum;
code = code % this.charTable.length;
crypt = crypt + this.charTable.charAt(code);
checkSum = checkSum + code;
i++;
}
checkSum = checkSum % this.charTable.length;
return((crypt + "") + this.charTable.charAt(checkSum));
};
_global.api.highscore.charTable = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&=.";
_global.api.highscore.keystring = "whytheheckdoyouwasteyourtimehackingthishighscorelist";
_global.api.highscore.keystring2 = "AnotherKey4You2FindOut4815jiagIOm30JK";
_global.api.highscore.urlSubmit = "http://www.neodelight.com/v4/high_enter.php";
_global.api.highscore.initSession();
#endinitclip
_visible = false;
Symbol 107 MovieClip Frame 1
stop();
_visible = false;
Symbol 107 MovieClip Frame 2
ufoScore = (int(Math.random() * 6) * 50) + 50;
_root.score = _root.score + ufoScore;
_root.setScore();
Symbol 115 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 () {
_global.api.highscore.submit("spacevaders", "", _level0.score, 0);
trace("score: " + _level0.score);
_root.gotoAndStop("menu");
};
ok_btn.onKeyDown = function () {
if (Key.getCode() == 13) {
Key.removeListener(ok_btn);
this.onRelease();
}
};
Key.addListener(ok_btn);
no_btn.onRelease = function () {
_root.gotoAndStop("menu");
};