Frame 1
stop();
Stage.showMenu = false;
this.onEnterFrame = function () {
var _local1 = this;
sofar = _local1.getBytesLoaded();
total = _local1.getBytesTotal();
pc_txt.text = int((sofar / total) * 100) + "%";
if (sofar == total) {
delete _local1.onEnterFrame;
nextFrame();
}
};
Frame 2
stop();
clearInterval(beatTimeout);
Key.removeListener(keyListener);
MovieClip.prototype.wrapPos = function () {
var _local1 = this;
if (_local1._x > (xMax + (_local1._width / 2))) {
if (_local1._name == "saucer_mc") {
_local1.hideSaucer();
} else {
_local1._x = _local1._x - (xMax + _local1._width);
}
}
if (_local1._y > (yMax + (_local1._height / 2))) {
_local1._y = _local1._y - (yMax + _local1._height);
}
if (_local1._x < ((-_local1._width) / 2)) {
if (_local1._name == "saucer_mc") {
_local1.hideSaucer();
} else {
_local1._x = _local1._x + (xMax + _local1._width);
}
}
if (_local1._y < ((-_local1._height) / 2)) {
_local1._y = _local1._y + (yMax + _local1._height);
}
};
introMover = function () {
var _local1 = this;
_local1._x = _local1._x + _local1.vx;
_local1._y = _local1._y + _local1.vy;
_local1.wrapPos();
};
introAsteroids = function () {
var _local1 = 10;
while (_local1--) {
var _local3 = Math.random() * (Math.PI*2);
var _local2 = [100, 50, 25][_local1 % 3];
intro_mc.attachMovie("asteroid", _local1, _local1, {vx:Math.sin(_local3) * 1.5, vy:Math.cos(_local3) * 1.5, _x:Math.random() * xMax, _y:Math.random() * yMax, _xscale:_local2, _yscale:_local2, onEnterFrame:introMover}).gotoAndStop((_local1 % 4) + 1);
}
};
game_so = SharedObject.getLocal("neaveAsteroids");
score = 0;
xMax = 500;
yMax = 375;
introAsteroids();
playGame_btn.onRelease = function () {
play();
};
highScores_btn.onRelease = function () {
gotoAndStop (4);
};
neave_btn.onRelease = function () {
getURL ("http://www.neave.com/games/", "_blank");
};
Frame 3
stop();
spaceship_mc.gotoAndStop(1);
spaceship_mc._visible = (spaceship_mc.hit_mc._visible = (safeArea_mc._visible = (gameOver_mc._visible = (quitGame_mc._visible = (missile0_mc._visible = (missile1_mc._visible = (missile2_mc._visible = (missile3_mc._visible = (missile4_mc._visible = (saucer_mc._visible = false))))))))));
dx = (dy = (explodeNum = (asteroidNum = (scoreMod = (score = 0)))));
level = 1;
lives = 3;
friction = 0.98;
rads = (Math.PI/180);
leftKey = (rightKey = (upKey = (fireKey = (paused = (exploded = (beatToggle = false))))));
asteroids_mc.createEmptyMovieClip("explode_mc", 0);
beat1_sound = new Sound(this);
beat1_sound.attachSound("beat1");
beat2_sound = new Sound(this);
beat2_sound.attachSound("beat2");
thrust_sound = new Sound(spaceship_mc);
thrust_sound.attachSound("thrust");
saucerBig_sound = new Sound(saucer_mc);
saucerBig_sound.attachSound("saucerBig");
saucerSmall_sound = new Sound(saucer_mc);
saucerSmall_sound.attachSound("saucerSmall");
setLives = function () {
lives_mc[lives].removeMovieClip();
var _local1 = 0;
while (_local1 < lives) {
var _local2 = lives_mc.attachMovie("spaceship", _local1, _local1, {_x:_local1 * 15, _xscale:60, _yscale:60});
_local2.gotoAndStop(1);
_local2.hit_mc._visible = false;
_local1++;
}
};
setLives();
keyListener = new Object();
keyListener.onKeyDown = function () {
switch (Key.getCode()) {
case 37 :
leftKey = true;
return;
case 39 :
rightKey = true;
return;
case 38 :
if (paused) {
return(undefined);
}
if (!upKey) {
thrust_sound.start(0, 1000);
}
upKey = true;
spaceship_mc.play();
return;
case 32 :
fireKey = true;
return;
case 80 :
if (!quitGame_mc._visible) {
paused = !paused;
pauseSaucer();
}
return;
case 81 :
paused = (quitGame_mc._visible = true);
return;
case 78 :
if (quitGame_mc._visible) {
paused = (quitGame_mc._visible = false);
pauseSaucer();
}
return;
case 89 :
clearInterval(hyperTimeout);
clearInterval(newShipTimeout);
clearInterval(newGameTimeout);
gotoAndStop (2);
return;
case 16 :
if (!(spaceship_mc._visible && (!paused))) {
break;
}
spaceship_mc._visible = false;
spaceship_mc.gotoAndStop(1);
leftKey = (rightKey = (upKey = (fireKey = false)));
dx = (dy = 0);
thrust_sound.stop();
hyperTimeout = setInterval(hyperspace, 500);
}
};
keyListener.onKeyUp = function () {
switch (Key.getCode()) {
case 37 :
leftKey = false;
return;
case 39 :
rightKey = false;
return;
case 38 :
upKey = false;
thrust_sound.stop();
spaceship_mc.gotoAndStop(1);
return;
case 32 :
fireKey = false;
}
};
spaceship_mc.onEnterFrame = function () {
var _local2 = this;
if (paused || (!_local2._visible)) {
} else {
if (leftKey) {
_local2._rotation = _local2._rotation - 10;
}
if (rightKey) {
_local2._rotation = _local2._rotation + 10;
}
var vx = Math.sin(_local2._rotation * rads);
var vy = (-Math.cos(_local2._rotation * rads));
if (upKey) {
dx = dx + (vx / 4);
dy = dy + (vy / 4);
}
dx = dx * friction;
dy = dy * friction;
_local2._x = _local2._x + dx;
_local2._y = _local2._y + dy;
_local2.wrapPos();
if (fireKey) {
fireKey = false;
var _local1 = 4;
var _local3 = -1;
while (_local1--) {
if (!_root[("missile" + _local1) + "_mc"]._visible) {
_local3 = _local1;
break;
}
}
if (_local3 != -1) {
var _mc = _root[("missile" + _local3) + "_mc"];
_mc.fuse = 24;
_mc.vx = (vx * 10) + dx;
_mc.vy = (vy * 10) + dy;
_mc._x = _local2._x + (vx * 10);
_mc._y = _local2._y + (vy * 10);
_mc._visible = true;
_mc.onEnterFrame = missileMover;
sound_mc.gotoAndPlay("fire");
}
}
var s = int(score / 10000);
if (scoreMod != s) {
scoreMod = s;
lives++;
setLives();
sound_mc.gotoAndPlay("extra");
}
if (((missile4_mc.hitTest(_local2.hit_mc) && (!exploded)) && (_local2._visible)) && (missile4_mc._visible)) {
missile4_mc._visible = false;
exploded = true;
explodeSpaceship();
}
}
};
saucer_mc.hideSaucer = function () {
saucerBig_sound.stop();
saucerSmall_sound.stop();
this._visible = false;
delete this.onEnterFrame;
};
pauseSaucer = function () {
if (saucer_mc._visible) {
if (paused) {
saucerBig_sound.stop();
saucerSmall_sound.stop();
} else if (saucer_mc.small) {
saucerSmall_sound.start(0, 80);
} else {
saucerBig_sound.start(0, 80);
}
}
};
explodeSaucer = function () {
saucer_mc.hideSaucer();
var i = 6;
while (i--) {
var _local1 = Math.random() * (Math.PI*2);
var _local3 = Math.sin(_local1) * 2;
var _local2 = Math.cos(_local1) * 2;
asteroids_mc.explode_mc.attachMovie("explosion", explodeNum, explodeNum, {vx:_local3, vy:_local2, fuse:Math.ceil(Math.random() * 40), _x:((_local3 * Math.random()) * 4) + saucer_mc._x, _y:((_local2 * Math.random()) * 4) + saucer_mc._y, onEnterFrame:explodeMover});
explodeNum++;
}
sound_mc.gotoAndPlay("bangMedium");
};
explodeSpaceship = function () {
spaceship_mc._visible = false;
explode_mc._x = spaceship_mc._x;
explode_mc._y = spaceship_mc._y;
lives--;
setLives();
var _local2 = 4;
while (_local2--) {
var _local1 = explode_mc.createEmptyMovieClip(_local2, _local2);
_local1.vx = Math.sin(Math.random() * (Math.PI*2));
_local1.vy = Math.cos(Math.random() * (Math.PI*2));
_local1.fuse = Math.ceil(Math.random() * 30) + 10;
_local1._x = (Math.random() * 12) - 6;
_local1._y = (Math.random() * 12) - 6;
_local1._rotation = Math.random() * 360;
_local1.lineStyle(0, 16777215);
_local1.moveTo(0, -8);
_local1.lineTo(0, 8);
_local1.onEnterFrame = explodeMover;
}
if (lives > 0) {
newShipTimeout = setInterval(newSpaceship, 1500);
} else {
gameOver_mc.gotoAndPlay(2);
gameOver_mc._visible = true;
quitGame_mc._visible = false;
Key.removeListener(keyListener);
clearInterval(hyperTimeout);
clearInterval(newShipTimeout);
clearInterval(newGameTimeout);
thrust_sound.stop();
saucerBig_sound.stop();
saucerSmall_sound.stop();
}
sound_mc.gotoAndPlay("bangMedium");
};
explodeMover = function () {
var _local1 = this;
if (paused) {
} else {
_local1._x = _local1._x + _local1.vx;
_local1._y = _local1._y + _local1.vy;
_local1.fuse--;
if (_local1.fuse < 0) {
_local1.removeMovieClip();
}
}
};
missileMover = function () {
var _local1 = this;
if (paused) {
} else {
_local1._x = _local1._x + _local1.vx;
_local1._y = _local1._y + _local1.vy;
_local1.wrapPos();
_local1.fuse--;
if (_local1.fuse == 0) {
_local1._visible = false;
delete _local1.onEnterFrame;
}
}
};
saucerMover = function () {
var _local1 = this;
if (paused) {
} else {
_local1._x = _local1._x + _local1.vx;
if (Math.random() < 0.02) {
_local1.vy = (int(Math.random() * 3) - 1) * 2;
}
if (_local1.vy != 0) {
_local1._y = _local1._y + _local1.vy;
}
_local1.wrapPos();
var _local2 = 4;
while (_local2--) {
var _local3 = _root[("missile" + _local2) + "_mc"];
if (_local3._visible) {
if (_local3.hitTest(_local1)) {
_local3._visible = false;
explodeSaucer();
if (_local1.small) {
score = score + 1000;
} else {
score = score + 200;
}
}
}
}
var _local3 = missile4_mc;
if ((!_local3._visible) && (Math.random() < 0.1)) {
var angle = ((_local1.small && (spaceship_mc._visible)) ? (Math.atan2(((spaceship_mc._x - _local1._x) + (Math.random() * 64)) - 32, ((_local1._y - spaceship_mc._y) + (Math.random() * 64)) - 32)) : (Math.random() * (Math.PI*2)));
_local3.fuse = 24;
_local3.vx = Math.sin(angle) * 8;
_local3.vy = Math.cos(angle) * -8;
_local3._x = _local1._x + _local3.vx;
_local3._y = _local1._y + (_local3.vy * 2);
_local3._visible = true;
_local3.onEnterFrame = missileMover;
sound_mc.gotoAndPlay("fire");
}
if ((spaceship_mc.hit_mc.hitTest(_local1) && (!exploded)) && (spaceship_mc._visible)) {
exploded = true;
explodeSpaceship();
}
}
};
asteroidMover = function () {
var _local1 = this;
if (paused) {
} else {
_local1._x = _local1._x + _local1.vx;
_local1._y = _local1._y + _local1.vy;
_local1.wrapPos();
var asteroidHit = false;
var spaceshipShot = false;
if (saucer_mc._visible && (saucer_mc.hitTest(_local1))) {
asteroidHit = true;
explodeSaucer();
}
if ((spaceship_mc.hit_mc.hitTest(_local1) && (!exploded)) && (spaceship_mc._visible)) {
exploded = (asteroidHit = (spaceshipShot = true));
explodeSpaceship();
}
var _local3 = 5;
while (_local3--) {
var _local2 = _root[("missile" + _local3) + "_mc"];
if (_local2._visible && (_local2.hitTest(_local1))) {
_local2._visible = false;
asteroidHit = true;
if (_local3 < 4) {
spaceshipShot = true;
}
break;
}
}
if (asteroidHit) {
var s = ((_local1._xscale = (_local1._yscale = _local1._yscale / 2)));
var angle = (Math.random() * (Math.PI*2));
_local1.vx = _local1.vx + Math.sin(angle);
_local1.vy = _local1.vy + Math.cos(angle);
asteroidCount--;
var j = (int(s / 25) + 4);
while (j--) {
var angle = (Math.random() * (Math.PI*2));
var vx = (Math.sin(angle) * 2);
var vy = (Math.cos(angle) * 2);
asteroids_mc.explode_mc.attachMovie("explosion", explodeNum, explodeNum, {vx:vx, vy:vy, fuse:Math.ceil(Math.random() * s), _x:((vx * Math.random()) * 4) + _local1._x, _y:((vy * Math.random()) * 4) + _local1._y, onEnterFrame:explodeMover});
explodeNum++;
}
if (s < 25) {
_local1.removeMovieClip();
sound_mc.gotoAndPlay("bangSmall");
if (spaceshipShot) {
score = score + 100;
}
} else {
if (s == 50) {
sound_mc.gotoAndPlay("bangLarge");
if (spaceshipShot) {
score = score + 20;
}
} else {
sound_mc.gotoAndPlay("bangMedium");
if (spaceshipShot) {
score = score + 50;
}
}
_local1.gotoAndStop((_local3 % 4) + 1);
var angle = (Math.random() * (Math.PI*2));
makeAsteroid(_local1._x, _local1._y, _local1.vx + Math.sin(angle), _local1.vy + Math.cos(angle), s);
}
}
}
};
makeAsteroid = function (x, y, vx, vy, s) {
asteroidNum++;
var _local1 = asteroids_mc.attachMovie("asteroid", asteroidNum, asteroidNum, {vx:vx, vy:vy, _x:x, _y:y, _xscale:s, _yscale:s, onEnterFrame:asteroidMover});
_local1.gotoAndStop((asteroidNum % 4) + 1);
return(_local1);
};
hyperspace = function () {
if (paused) {
return(undefined);
}
with (spaceship_mc) {
_visible = true;
_x = (Math.random() * (xMax - (_width * 2))) + _width;
_y = (Math.random() * (yMax - (_height * 2))) + _height;
}
clearInterval(hyperTimeout);
};
beatSound = function () {
if (paused) {
return(undefined);
}
beatToggle = !beatToggle;
if (beatToggle) {
beat1_sound.start();
} else {
beat2_sound.start();
}
if (gameOver_mc._visible) {
return(undefined);
}
if (beatCount > 300) {
beatCount = beatCount - 10;
clearInterval(beatTimeout);
beatTimeout = setInterval(beatSound, beatCount);
}
if (((beatCount < 700) && (!saucer_mc._visible)) && (Math.random() < 0.05)) {
if ((beatCount < 400) && (Math.random() < 0.4)) {
saucer_mc._xscale = (saucer_mc._yscale = 50);
saucer_mc.small = true;
saucerSmall_sound.start(0, 100);
} else {
saucer_mc._xscale = (saucer_mc._yscale = 100);
saucer_mc.small = false;
saucerBig_sound.start(0, 100);
}
if (Math.random() < 0.5) {
saucer_mc.vx = -2;
saucer_mc._x = (saucer_mc._width / 2) + xMax;
} else {
saucer_mc.vx = 2;
saucer_mc._x = saucer_mc._width / -2;
}
saucer_mc.vy = 0;
saucer_mc._y = Math.random() * yMax;
saucer_mc._visible = true;
saucer_mc.onEnterFrame = saucerMover;
}
if ((asteroidCount == 0) && (!saucer_mc._visible)) {
clearInterval(beatTimeout);
level++;
newGameTimeout = setInterval(newGame, 1000);
}
};
newSpaceship = function () {
spaceship_mc._x = 250;
spaceship_mc._y = 190;
spaceship_mc._rotation = 0;
var _local1 = false;
for (var _local2 in asteroids_mc) {
if (spaceship_mc.hitTest(asteroids_mc[_local2])) {
_local1 = true;
break;
}
}
if (!_local1) {
spaceship_mc._visible = true;
exploded = false;
dx = (dy = 0);
clearInterval(newShipTimeout);
}
};
newGame = function () {
var _local3 = ((level < 7) ? (level + 3) : 10);
asteroidCount = _local3 * 7;
while (_local3--) {
var _local2 = Math.random() * (Math.PI*2);
var _local1 = makeAsteroid(Math.random() * xMax, Math.random() * yMax, Math.sin(_local2) * 1.5, Math.cos(_local2) * 1.5, 100);
if (_local1.hitTest(spaceship_mc) || (_local1.hitTest(safeArea_mc))) {
_local3++;
asteroidNum--;
}
}
beatCount = ((level < 7) ? (1100 - (level * 100)) : 400);
beatSound();
Key.addListener(keyListener);
clearInterval(newGameTimeout);
};
newGameTimeout = setInterval(newGame, 1000);
newShipTimeout = setInterval(newSpaceship, 1100);
Frame 4
stop();
clearInterval(beatTimeout);
showScores = function () {
var _local1 = 10;
while (_local1 > 0) {
var n = scoreboard_lv["name" + (page + _local1)];
var _local3 = scoreboard_lv["score" + (page + _local1)];
var _local2 = this[("line" + _local1) + "_mc"];
_local2.rank_txt.text = (page + _local1) + ".";
_local2.name_txt.text = (n.length ? (n.toUpperCase()) : "-");
_local2.score_txt.text = (_local3.length ? (_local3) : "-");
_local2._visible = true;
loading_mc._visible = false;
_local1--;
}
};
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 = "asteroids";
scoreboard_lv.sendAndLoad("http://www.java-gaming.com/misc/asteroids/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);
};
Symbol 38 MovieClip Frame 1
stop();
Symbol 38 MovieClip Frame 3
stop();
Symbol 38 MovieClip Frame 5
stop();
Symbol 38 MovieClip Frame 7
stop();
Symbol 38 MovieClip Frame 9
stop();
Symbol 38 MovieClip Frame 11
stop();
Symbol 46 MovieClip Frame 1
stop();
Symbol 46 MovieClip Frame 61
stop();
name_txt.restrict = "A-Z 0-9.\\-";
if (_root.game_so.data.playerName.length > 0) {
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 61 MovieClip Frame 1
stop();
errorMsg = "";