Combined Code
frame 1 {
if ((_framesloaded / _totalframes) * 100 > 90) {
preloader._visible = false;
} else {
preloader._visible = true;
}
}
movieClip 3 {
frame 1 {
bLoaded = _parent.getBytesLoaded();
bTotal = _parent.getBytesTotal();
factor = Math.ceil((bLoaded / bTotal) * 100);
if (factor < fcomp) {
_parent.stop();
percentloaded = Math.ceil((bTotal - bLoaded) * 9 / bTotal);
} else {
_parent.play();
}
}
frame 1 {
percentage.text = percentloaded;
percentage.textColor = color3;
percentage.textFont = fText;
}
frame 1 {
function drawProCircle(r, x, y, p, line, fill, trans) {
lineStyle(1, line);
beginFill(fill, trans);
moveTo(x + r, y);
var angle = 1;
while (angle <= p) {
var endx = r * Math.cos(angle * Math.PI / 180);
var endy = r * Math.sin(angle * Math.PI / 180);
var cx = endx;
var cy = endy;
this.curveTo(cx + x, cy + y, endx + x, endy + y);
angle += 1;
}
this.lineTo(x, y);
this.lineTo(x + r, y);
}
this.clear();
p = Math.ceil((bLoaded / bTotal) * 9 * 360);
p1 = int(p / 360);
if (p > 360) {
p -= p1 * 360;
}
drawProCircle(r, 0, 0, p, color1, color2, 100);
drawProCircle(r / 2, 0, 0, p, color4, color5, 100);
}
frame 2 {
gotoAndPlay(1);
}
}
instance preloader of movieClip 3 {
onClipEvent (initialize) {
r = 100;
color1 = 16777215;
color2 = 10066329;
color4 = 16777215;
color5 = 13421772;
color3 = 0;
fcomp = 100;
}
}
frame 2 {
function initialize() {
lives = 5;
cash = 0;
cashDisplay = 0;
gameState = 'stop';
progress_bar_mc.gotoAndPlay(1);
}
function updateObstacle(obstacleTargetName) {
if (gameState == 'play') {
obstacleTargetName.play();
}
if (gameState == 'stop') {
obstacleTargetName.stop();
}
}
function testForCollision(xMin, xMax) {
if (car_mc._x >= xMin & car_mc._x <= xMax) {
car_mc._y -= 6;
sound_mc.gotoAndPlay('crash');
lives -= 1;
if (lives == 0) {
gotoAndPlay(88);
}
}
}
function testForCashCollision(xMin, xMax) {
if (car_mc._x >= xMin & car_mc._x <= xMax) {
car_mc._y -= 6;
sound_mc.gotoAndPlay('cash_register');
cash += 10000;
num = (String(cash)).split('.');
commanum = '';
if (num.length == 2) {
commanum = '.' + num[1];
}
if (length(num[0]) > 3) {
commanum = (String(num[0])).substr(length(num[0]) - 3, 3) + commanum;
digit = length(num[0]) - 6;
while (digit >= 0) {
commanum = (String(num[0])).substr(digit, 3) + ',' + commanum;
digit -= 3;
}
if (digit > -3) {
commanum = (String(num[0])).substr(0, digit + 3) + ',' + commanum;
}
} else {
commanum = num[0] + commanum;
}
cashDisplay = commanum;
}
}
}
frame 2 {
initialize();
stop();
this.onMouseUp = function () {
gotoAndPlay(10);
};
}
movieClip 8 {
}
movieClip 17 {
}
movieClip 18 {
instance of movieClip 8 {
onClipEvent (load) {
this._alpha = 0;
act = '1';
}
onClipEvent (enterFrame) {
if (act == '1') {
this._alpha += 7;
if (this._alpha > 60 + tr) {
tr = random(40);
act = '2';
}
}
if (act == '2') {
this._alpha -= 5;
if (this._alpha < tr) {
tr = random(40);
act = '1';
}
}
}
}
}
movieClip 26 {
frame 1 {
stop();
}
frame 24 {
gotoAndPlay(1);
}
frame 39 {
gotoAndPlay(1);
}
frame 79 {
gotoAndPlay(1);
}
frame 80 {
gotoAndPlay(1);
}
frame 141 {
gotoAndPlay(1);
}
}
frame 10 {
stop();
this.onMouseUp = function () {
gotoAndPlay(20);
};
}
movieClip 31 {
}
movieClip 35 {
}
movieClip 42 {
frame 28 {
gotoAndPlay(17);
}
}
frame 20 {
this.onMouseUp = function () {};
}
movieClip 45 {
}
instance of movieClip 45 {
onClipEvent (enterFrame) {
if (_x > -221) {
_x = _x - 0.5;
} else {
_x = 675;
}
}
}
instance of movieClip 45 {
onClipEvent (enterFrame) {
if (_x > -221) {
_x = _x - 0.5;
} else {
_x = 675;
}
}
}
movieClip 48 {
}
movieClip 55 {
frame 1 {
stop();
}
instance landscape_mc of movieClip 48 {
onClipEvent (load) {
startX = this._x;
}
onClipEvent (enterFrame) {
leftKey = 37;
rightKey = 39;
scrollIncrement = 2;
scrollLimit = 18;
if (_parent.gameState == 'play') {
if (Key.isDown(leftKey)) {
if (this._x < startX + scrollLimit) {
this._x += scrollIncrement;
}
}
if (Key.isDown(rightKey)) {
if (this._x > startX - scrollLimit) {
this._x -= scrollIncrement;
}
}
}
}
}
frame 20 {
stop();
}
frame 37 {
stop();
}
frame 54 {
stop();
}
}
instance landscape_mc of movieClip 55 {
onClipEvent (load) {
startX = this._x;
}
onClipEvent (enterFrame) {
leftKey = 37;
rightKey = 39;
scrollIncrement = 2;
scrollLimit = 18;
if (_parent.gameState == 'play') {
if (Key.isDown(leftKey)) {
if (this._x < startX + scrollLimit) {
this._x += scrollIncrement;
}
}
if (Key.isDown(rightKey)) {
if (this._x > startX - scrollLimit) {
this._x -= scrollIncrement;
}
}
}
}
}
movieClip 62 {
frame 1 {
stop();
}
}
instance road_mc of movieClip 62 {
onClipEvent (enterFrame) {
if (_parent.gameState == 'play') {
nextFrame();
play();
}
if (_parent.gameState == 'stop') {
stop();
}
}
}
movieClip 67 {
}
movieClip 70 {
}
movieClip 74 {
}
movieClip 79 {
}
movieClip 81 {
}
movieClip 82 {
}
movieClip 83 {
frame 1 {
x_value = _x;
x_target = x_value;
acc = 10;
b = 1.45;
}
instance car_body_mc of movieClip 82 {
onClipEvent (load) {
y = _y;
}
onClipEvent (enterFrame) {
if (_parent._parent.gameState == 'play') {
_y = y + random(2) - 1;
}
}
}
frame 2 {
vx = (Number(vx) + Number((x_target - x_value) * 1 / acc)) / b;
x_value = Number(x_value) + Number(vx);
_x = x_value;
}
frame 3 {
gotoAndPlay(2);
}
}
instance car_mc of movieClip 83 {
onClipEvent (enterFrame) {
if (_parent.gameState == 'play') {
car_body_mc.brakelights._alpha = 0;
}
if (_parent.gameState == 'stop') {
car_body_mc.brakelights._alpha = 100;
}
}
}
movieClip 91 {
frame 720 {
_parent.landscape_mc.gotoAndPlay('stage_02');
}
frame 745 {
_parent.stage_completed_mc.gotoAndPlay('stage_1_completed');
}
frame 1440 {
_parent.landscape_mc.gotoAndPlay('stage_03');
}
frame 1467 {
_parent.stage_completed_mc.gotoAndPlay('stage_2_completed');
}
frame 2160 {
_parent.landscape_mc.gotoAndPlay('stage_04');
}
frame 2185 {
_parent.stage_completed_mc.gotoAndPlay('stage_3_completed');
}
frame 2880 {
_parent.gotoAndPlay('congratulations');
stop();
}
}
instance progress_bar_mc of movieClip 91 {
onClipEvent (enterFrame) {
if (_parent.gameState == 'play') {
nextFrame();
play();
}
if (_parent.gameState == 'stop') {
stop();
}
}
}
movieClip 99 {
}
movieClip 103 {
}
movieClip 106 {
}
movieClip 109 {
}
frame 74 {
stopAllSounds();
gotoAndPlay(75);
}
frame 75 {
gameState = 'play';
sound_mc.gotoAndPlay('screech');
smoke_mc.gotoAndPlay('puff');
stop();
}
movieClip 113 {
}
movieClip 114 {
frame 1 {
function randomTreeSequence() {
randomSequenceNumber = Math.floor(Math.random() * 3 + 1);
if (randomSequenceNumber == 1) {
gotoAndPlay(1);
}
if (randomSequenceNumber == 2) {
gotoAndPlay(28);
}
if (randomSequenceNumber == 3) {
gotoAndPlay(55);
}
}
}
frame 27 {
randomTreeSequence();
}
frame 54 {
randomTreeSequence();
}
frame 81 {
randomTreeSequence();
}
}
instance trees_and_signs_mc of movieClip 114 {
onClipEvent (load) {
this.gotoAndStop('start_position');
}
onClipEvent (enterFrame) {
if (_parent.gameState == 'play') {
this.play();
}
if (_parent.gameState == 'stop') {
this.stop();
}
}
}
movieClip 129 {
frame 1 {
xMin = 60;
xMax = 123;
stop();
}
frame 21 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 22 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 25 {
gotoAndPlay(117);
}
frame 39 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 40 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 42 {
gotoAndPlay(117);
}
frame 57 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 58 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 59 {
gotoAndPlay(117);
}
frame 75 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 76 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 78 {
gotoAndPlay(117);
}
frame 94 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 95 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 97 {
gotoAndPlay(117);
}
frame 113 {
_parent.testForCashCollision(this.xMin, this.xMax);
}
frame 114 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 116 {
gotoAndPlay(117);
}
frame 117 {
gotoAndPlay(this._currentFrame + Math.floor(Math.random() * 75 + 1));
}
frame 192 {
randomObstacle = Math.floor(Math.random() * 6 + 1);
if (randomObstacle == 1) {
gotoAndPlay(9);
} else {
if (randomObstacle == 2) {
gotoAndPlay(26);
} else {
if (randomObstacle == 3) {
gotoAndPlay(43);
} else {
if (randomObstacle == 4) {
gotoAndPlay(60);
} else {
if (randomObstacle == 5) {
gotoAndPlay(79);
} else {
if (randomObstacle == 6) {
gotoAndPlay(98);
}
}
}
}
}
}
}
}
instance obstacle_01_mc of movieClip 129 {
onClipEvent (load) {
this.gotoAndStop('starting_line');
}
onClipEvent (enterFrame) {
_parent.updateObstacle(eval(this._target));
}
}
movieClip 132 {
}
movieClip 141 {
frame 1 {
xMin = 120;
xMax = 323;
stop();
}
frame 22 {
smoke_mc.gotoAndPlay('puff');
}
frame 24 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 25 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 29 {
gotoAndPlay(135);
}
instance of movieClip 132 {
onClipEvent (load) {
_yscale = 1;
_xscale = 1;
}
onClipEvent (enterFrame) {
dist += 0.03 + dist / 15;
_yscale = _yscale + dist;
_xscale = _xscale + dist;
obs += 1;
if (obs > 80) {
_yscale = 1;
_xscale = 1;
obs = 1;
dist = 0;
}
}
}
frame 43 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 44 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 50 {
gotoAndPlay(135);
}
frame 66 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 67 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 71 {
gotoAndPlay(135);
}
frame 89 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 90 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 92 {
gotoAndPlay(135);
}
frame 106 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 107 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 113 {
gotoAndPlay(135);
}
frame 127 {
_parent.testForCashCollision(this.xMin, this.xMax);
}
frame 128 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 134 {
gotoAndPlay(135);
}
frame 135 {
gotoAndPlay(this._currentFrame + Math.floor(Math.random() * 75 + 1));
}
frame 210 {
randomObstacle = Math.floor(Math.random() * 6 + 1);
if (randomObstacle == 1) {
gotoAndPlay(9);
} else {
if (randomObstacle == 2) {
gotoAndPlay(30);
} else {
if (randomObstacle == 3) {
gotoAndPlay(51);
} else {
if (randomObstacle == 4) {
gotoAndPlay(72);
} else {
if (randomObstacle == 5) {
gotoAndPlay(93);
} else {
if (randomObstacle == 6) {
gotoAndPlay(114);
}
}
}
}
}
}
}
}
instance obstacle_02_mc of movieClip 141 {
onClipEvent (load) {
this.gotoAndStop('starting_line');
}
onClipEvent (enterFrame) {
_parent.updateObstacle(eval(this._target));
}
}
movieClip 146 {
frame 1 {
xMin = 320;
xMax = 384;
stop();
}
frame 25 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 26 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 29 {
gotoAndPlay(128);
}
frame 45 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 46 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 50 {
gotoAndPlay(128);
}
frame 61 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 62 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 64 {
gotoAndPlay(128);
}
frame 82 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 83 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 85 {
gotoAndPlay(128);
}
frame 103 {
_parent.testForCollision(this.xMin, this.xMax);
}
frame 104 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 106 {
gotoAndPlay(128);
}
frame 124 {
_parent.testForCashCollision(this.xMin, this.xMax);
}
frame 125 {
if (_parent.car_mc._y != _parent.car_mc.origY) {
_parent.car_mc._y = _parent.car_mc.origY;
}
}
frame 127 {
gotoAndPlay(128);
}
frame 128 {
gotoAndPlay(this._currentFrame + Math.floor(Math.random() * 75 + 1));
}
frame 203 {
randomObstacle = Math.floor(Math.random() * 6 + 1);
if (randomObstacle == 1) {
gotoAndPlay(9);
} else {
if (randomObstacle == 2) {
gotoAndPlay(30);
} else {
if (randomObstacle == 3) {
gotoAndPlay(51);
} else {
if (randomObstacle == 4) {
gotoAndPlay(65);
} else {
if (randomObstacle == 5) {
gotoAndPlay(86);
} else {
if (randomObstacle == 6) {
gotoAndPlay(107);
}
}
}
}
}
}
}
}
instance obstacle_06_mc of movieClip 146 {
onClipEvent (load) {
this.gotoAndStop('starting_line');
}
onClipEvent (enterFrame) {
_parent.updateObstacle(eval(this._target));
}
}
instance car_mc of movieClip 83 {
onClipEvent (load) {
origY = _y;
}
onClipEvent (enterFrame) {
if (Key.isDown(37) and x_target > 80) {
x_target -= 50;
if (_parent.sound_mc._currentFrame == 1) {
_parent.sound_mc.gotoAndPlay('screech');
}
car_body_mc.signal_left._alpha = 100;
} else {
car_body_mc.signal_left._alpha = 0;
}
if (Key.isDown(39) and x_target < 350) {
x_target += 50;
if (_parent.sound_mc._currentFrame == 1) {
_parent.sound_mc.gotoAndPlay('screech');
}
car_body_mc.signal_right._alpha = 100;
} else {
car_body_mc.signal_right._alpha = 0;
}
if (Key.isDown(37)) {
dir = 0.5;
}
if (Key.isDown(39)) {
dir = -0.5;
}
if (_parent.gameState == 'play') {
car_body_mc.brakelights._alpha = 0;
}
if (_parent.gameState == 'stop') {
car_body_mc.brakelights._alpha = 100;
}
}
}
movieClip 149 {
frame 24 {
stop();
}
}
movieClip 153 {
frame 1 {
stop();
}
frame 25 {
gotoAndPlay(1);
}
frame 49 {
gotoAndPlay(1);
}
frame 73 {
gotoAndPlay(1);
}
}
frame 88 {
sound_mc.gotoAndPlay('crash');
gameState = 'stop';
}
frame 115 {
stop();
}
movieClip 159 {
}
instance of movieClip 159 {
onClipEvent (keyUp) {
_parent.initialize();
_parent.gotoAndPlay('countdown');
}
onClipEvent (mouseUp) {
_parent.initialize();
_parent.gotoAndPlay('countdown');
}
}
frame 116 {
sound_mc.gotoAndPlay('congratulations');
gameState = 'stop';
}
frame 145 {
stop();
}