Frame 1
iStatus = 0;
setProperty("pBar", _xscale , 0);
Frame 2
iBytesTotal = _root.getBytesTotal();
iBytesLoaded = _root.getBytesLoaded();
iBytes = (iBytesLoaded / iBytesTotal) * 100;
setProperty("pBar", _xscale , iBytes);
sStatus = Math.floor(iBytes) add "%";
Frame 3
if (iBytes < 100) {
gotoAndPlay (2);
} else {
sStatus = "COMPLETE";
gotoAndPlay (4);
}
Frame 4
sStatus = "loaded";
stop();
gotoAndStop (5);
Frame 5
function genRandom() {
seed = a + Math.floor(Math.random() * ((b - a) + 1));
switch (seed) {
case 1 :
if (_root.target1._currentframe > 1) {
genRandom();
} else {
target1.gotoAndPlay(1);
launches++;
}
return;
case 2 :
if (_root.target2._currentframe > 1) {
genRandom();
} else {
target2.gotoAndPlay(1);
launches++;
}
return;
case 3 :
if (_root.target3._currentframe > 1) {
genRandom();
} else {
target3.gotoAndPlay(1);
launches++;
}
return;
case 4 :
if ((_root.target4._currentframe > 1) && (_root.target5._currentframe > 1)) {
genRandom();
} else {
_root.target4.gotoAndPlay(1);
_root.target5.gotoAndPlay(1);
launches++;
}
return;
case 5 :
if ((_root.target6._currentframe > 1) && (_root.target7._currentframe > 1)) {
genRandom();
} else {
_root.target6.gotoAndPlay(1);
_root.target7.gotoAndPlay(1);
launches++;
}
return;
case 6 :
if ((_root.target8._currentframe > 1) || (_root.target9._currentframe > 1)) {
genRandom();
} else {
_root.target8.gotoAndPlay(1);
_root.target9.gotoAndPlay(1);
launches++;
}
}
}
function restart1(vers1) {
if (vers1._currentframe == restartFrame) {
genRandom();
}
if (vers1._currentframe >= hitFrame) {
if (vers1.hitTest(_root.character.hitter)) {
if (_root.character._x > 450) {
_root.flashR.gotoAndPlay(2);
} else {
_root.flashL.gotoAndPlay(2);
}
collisions++;
playBadSound();
vers1.gotoAndStop(1);
if (collisions == 5) {
loseGame(collisions);
}
}
}
}
function restart2(vers3) {
if (vers3._currentframe == restartFrame) {
genRandom();
}
}
function score2(vers5) {
if (vers5._currentframe >= hitFrame) {
if (vers5.hitTest(_root.character.hitter)) {
if (_root.character._x > 450) {
_root.flashR.gotoAndPlay(2);
} else {
_root.flashL.gotoAndPlay(2);
}
collisions++;
playBadSound();
vers5.gotoAndStop(1);
if (collisions == 5) {
loseGame(collisions);
}
}
}
}
function targetStop(vers2) {
if (vers2._currentframe == missFrame) {
avoided++;
switch (avoided) {
case 30 :
level = 2;
_root.level2._visible = 1;
collisions = 0;
break;
case 60 :
level = 3;
_root.level3._visible = 1;
collisions = 0;
break;
case 90 :
level = 4;
_root.level4._visible = 1;
collisions = 0;
}
if (avoided == 120) {
playWinSound();
} else {
playGoodSound();
}
vers2.gotoAndStop(1);
}
}
function targetStop2(vers3) {
if (vers3._currentframe == missFrame) {
vers3.gotoAndStop(1);
}
}
function loseGame(miss) {
target1.gotoAndStop(1);
target2.gotoAndStop(1);
target3.gotoAndStop(1);
target4.gotoAndStop(1);
target5.gotoAndStop(1);
target6.gotoAndStop(1);
target7.gotoAndStop(1);
target8.gotoAndStop(1);
target9.gotoAndStop(1);
playLoseSound();
}
function levelJumper(item, levNum) {
if (levNum > 1) {
switch (levNum) {
case 2 :
if (item._currentframe == 13) {
item.gotoAndPlay(16);
}
if (item._currentframe == 28) {
item.gotoAndPlay(31);
}
if (item._currentframe == 43) {
hitFrame = 53;
item.gotoAndPlay(47);
}
return;
case 3 :
if (item._currentframe == 11) {
item.gotoAndPlay(16);
}
if (item._currentframe == 26) {
item.gotoAndPlay(31);
}
if (item._currentframe == 41) {
hitFrame = 56;
item.gotoAndPlay(50);
}
return;
case 4 :
if (item._currentframe == 9) {
item.gotoAndPlay(16);
}
if (item._currentframe == 24) {
item.gotoAndPlay(31);
}
if (item._currentframe != 39) {
break;
}
hitFrame = 58;
item.gotoAndPlay(53);
}
}
}
function playBadSound() {
badBeep = new Sound();
badBeep.attachSound("badSound");
badBeep.start();
}
function playGoodSound() {
goodBeep = new Sound();
goodBeep.attachSound("goodSound");
goodBeep.start();
}
function playLevelSound() {
levelBeep = new Sound();
levelBeep.attachSound("levelSound");
levelBeep.start();
}
function playStartSound() {
startBeep = new Sound();
startBeep.attachSound("startSound");
startBeep.start();
}
function playWinSound() {
winBeep = new Sound();
winBeep.attachSound("winSound");
winBeep.start();
}
function playLoseSound() {
loseBeep = new Sound();
loseBeep.attachSound("loseSound");
loseBeep.start();
}
avoided = 0;
collisions = 0;
launches = 0;
level = 1;
characterMove = 100;
restartFrame = 16;
hitFrame = 52;
missFrame = 61;
character._x = 220;
level2._visible = 0;
level3._visible = 0;
level4._visible = 0;
character.gotoAndStop("center");
flashL.gotoAndStop(1);
flashR.gotoAndStop(1);
target1.gotoAndStop(1);
target2.gotoAndStop(1);
target3.gotoAndStop(1);
target4.gotoAndStop(1);
target5.gotoAndStop(1);
target6.gotoAndStop(1);
target7.gotoAndStop(1);
target8.gotoAndStop(1);
target9.gotoAndStop(1);
a = 1;
b = 6;
flashL.onEnterFrame = function () {
with (flashL) {
if (_currentframe == 8) {
gotoAndStop(1);
}
}
};
flashR.onEnterFrame = function () {
with (flashR) {
if (_currentframe == 8) {
gotoAndStop(1);
}
}
};
character.onEnterFrame = function () {
with (character) {
if (key.isDown(37)) {
_x = _x - characterMove;
if (_x <= 150) {
_x = 90;
gotoAndStop("left");
} else {
_x = 220;
gotoAndStop("center");
}
}
if (key.isDown(39)) {
_x = _x + characterMove;
if (_x >= 200) {
_x = 370;
gotoAndStop("right");
} else {
_x = 220;
gotoAndStop("center");
}
}
if (avoided >= 120) {
level = 5;
target1.gotoAndStop(1);
target2.gotoAndStop(1);
target3.gotoAndStop(1);
target4.gotoAndStop(1);
target5.gotoAndStop(1);
target6.gotoAndStop(1);
target7.gotoAndStop(1);
target8.gotoAndStop(1);
target9.gotoAndStop(1);
}
}
};
target1.onEnterFrame = function () {
levelJumper(target1, level);
restart1(target1);
targetStop(target1);
};
target2.onEnterFrame = function () {
levelJumper(target2, level);
restart1(target2);
targetStop(target2);
};
target3.onEnterFrame = function () {
levelJumper(target3, level);
restart1(target3);
targetStop(target3);
};
target4.onEnterFrame = function () {
levelJumper(target4, level);
restart2(target4);
score2(target4);
targetStop(target4);
};
target6.onEnterFrame = function () {
levelJumper(target6, level);
restart2(target6);
score2(target6);
targetStop(target6);
};
target8.onEnterFrame = function () {
levelJumper(target8, level);
restart2(target8);
score2(target8);
targetStop(target8);
};
target5.onEnterFrame = function () {
levelJumper(target5, level);
score2(target5);
targetStop2(target5);
};
target7.onEnterFrame = function () {
levelJumper(target7, level);
score2(target7);
targetStop2(target7);
};
target9.onEnterFrame = function () {
levelJumper(target9, level);
score2(target9);
targetStop2(target9);
};
playStartSound();
genRandom();
resetButton.onRelease = function () {
avoided = 0;
collisions = 0;
launches = 0;
level = 1;
var i = 2;
while (i < 5) {
_root["level" + i]._visible = 0;
i++;
}
var i = 0;
while (i < 9) {
_root["target" + i].gotoAndStop(1);
i++;
}
playStartSound();
genRandom();
};