Frame 1
MochiAd.showPreGameAd({id:"f0cdd9cda144569f", res:"500x600"});
Frame 2
stop();
stopAllSounds();
var core = this;
var make_sound = function (mc_name, depth, volume, name) {
var _local2 = core.createEmptyMovieClip(mc_name, depth);
var _local1 = new Sound(_local2);
_local1.setVolume(volume);
_local1.attachSound(name);
return(_local1);
};
var mus = make_sound("bgmusic", 200, 100, "mus");
mus.start(0, 9999);
function animate(left) {
if (left == 0) {
if (bg._x > -650) {
bg._x = bg._x - 10;
tit._x = tit._x - 10;
btnUp._x = btnUp._x - 10;
btnLeft._x = btnLeft._x - 10;
btnRight._x = btnRight._x - 10;
messd._x = messd._x - 10;
} else if (bounce == false) {
if (bg._x > -675) {
bg._x = bg._x - 5;
tit._x = tit._x - 5;
btnUp._x = btnUp._x - 5;
btnLeft._x = btnLeft._x - 5;
btnRight._x = btnRight._x - 5;
messd._x = messd._x - 5;
} else {
bounce = true;
}
} else if (bg._x < -650) {
bg._x = bg._x + 5;
tit._x = tit._x + 5;
btnUp._x = btnUp._x + 5;
btnLeft._x = btnLeft._x + 5;
btnRight._x = btnRight._x + 5;
messd._x = messd._x + 5;
} else {
bounce = false;
anim = false;
gotoAndPlay (4);
}
} else if (left == 1) {
if (bg._x < -50) {
bg._x = bg._x + 10;
tit._x = tit._x + 10;
btnUp._x = btnUp._x + 10;
btnLeft._x = btnLeft._x + 10;
btnRight._x = btnRight._x + 10;
messd._x = messd._x + 10;
} else if (bounce == false) {
if (bg._x < -25) {
bg._x = bg._x + 5;
tit._x = tit._x + 5;
btnUp._x = btnUp._x + 5;
btnLeft._x = btnLeft._x + 5;
btnRight._x = btnRight._x + 5;
messd._x = messd._x + 5;
} else {
bounce = true;
}
} else if (bg._x > -50) {
bg._x = bg._x - 5;
tit._x = tit._x - 5;
btnUp._x = btnUp._x - 5;
btnLeft._x = btnLeft._x - 5;
btnRight._x = btnRight._x - 5;
messd._x = messd._x - 5;
} else {
bounce = false;
anim = false;
}
} else {
mess = "Good luck!";
if (bg._y < 575) {
bg._y = bg._y + 10;
tit._y = tit._y + 10;
btnUp._y = btnUp._y + 10;
btnLeft._y = btnLeft._y + 10;
btnRight._y = btnRight._y + 10;
messd._y = messd._y + 10;
} else if (bounce == false) {
if (bg._y < 600) {
bg._y = bg._y + 5;
tit._y = tit._y + 5;
btnUp._y = btnUp._y + 5;
btnLeft._y = btnLeft._y + 5;
btnRight._y = btnRight._y + 5;
messd._y = messd._y + 5;
} else {
bounce = true;
}
} else if (bg._y > 575) {
bg._y = bg._y - 5;
tit._y = tit._y - 5;
btnUp._y = btnUp._y - 5;
btnLeft._y = btnLeft._y - 5;
btnRight._y = btnRight._y - 5;
messd._x = messd._x - 5;
} else {
bounce = false;
anim = false;
}
if (!anim) {
gotoAndPlay (3);
}
}
}
stop();
var dispMess = "Welcome to Break Tris!";
var time = 300;
var messIndex = 0;
var _mochiads_game_id = "e09e840bfe92f8c9";
tit._alpha = 0;
btnUp._alpha = 0;
btnRight._alpha = 0;
messd._visible = false;
var fading = true;
var fadetimer = 0;
onEnterFrame = function () {
if (fading) {
fade();
}
if (anim) {
animate(left);
}
time--;
if (time == 0) {
changeMessage();
}
};
fade = function () {
if (fadetimer != 10) {
tit._alpha = tit._alpha + 10;
btnUp._alpha = btnUp._alpha + 10;
btnRight._alpha = btnRight._alpha + 10;
messd._alpha = messd._alpha + 10;
} else {
fading = false;
messd._visible = true;
}
fadetimer++;
};
var left;
changeMessage = function () {
if (messIndex == 0) {
dispMess = "Clearing the tetris grid completely\non level completion results\nin 100 bonus points";
} else if (messIndex == 1) {
dispMess = "Your score will increase while holding\nthe down key to speed up a falling shape";
} else if (messIndex == 2) {
dispMess = "Clearing the breakout grid completely\nbefore time runs out results in 10 bonus points";
} else if (messIndex == 3) {
dispMess = "With every level increase you get\nmore time on the breakout grid";
} else if (messIndex == 4) {
dispMess = "Have fun!";
messIndex = -1;
}
messIndex++;
mess = dispMess;
time = 300;
};
btnRight.onRollOver = function () {
mess = "Click here to learn how to play";
};
bg.onRollOver = function () {
mess = dispMess;
};
btnUp.onRollOver = function () {
mess = "Click here to start a new game";
};
btnRight.onRelease = function () {
anim = true;
left = 0;
};
btnUp.onRelease = function () {
anim = true;
left = 2;
};
var anim = false;
var bounce = false;
Frame 3
stop();
var tetris = false;
var breakout = false;
var gNum = 0;
var hasShape = false;
var timer = 0;
var prevInterval = 30;
var interval = 30;
var moveTimer = 0;
var rotTimer = 0;
slot = new Array();
i = 0;
while (i < 150) {
slot[i] = false;
i++;
}
occSlot = new Array();
bSlot = new Array();
i = 0;
while (i < 150) {
bSlot[i] = false;
i++;
}
var num = 0;
names = new Array();
i = 0;
while (i < 150) {
names[i] = "";
i++;
}
bNames = new Array();
i = 0;
while (i < 150) {
bNames[i] = "";
i++;
}
colors = new Array();
i = 0;
while (i < 150) {
colors[i] = 0;
i++;
}
bColors = new Array();
i = 0;
while (i < 150) {
bColors[i] = 0;
i++;
}
var FCOLOR;
var COLOR;
var currentShape;
var nextShape;
var rot = 0;
var score = 0;
var level = 1;
var lines = 0;
var bNum = 0;
var reqLines = 2;
xp._width = 0;
var anim = false;
var left = 0;
var bounce = false;
var levelLines = 0;
var stats = "0 / 2";
var xBall = -5;
var yBall = 5;
var time = 0;
var MILI = 0;
redx._visible = false;
var hasSound = true;
var fading = true;
grid._alpha = 0;
gO._alpha = 0;
btnSound._alpha = 0;
btnMenu._alpha = 0;
xBar._alpha = 0;
xp._alpha = 0;
statsBox._visible = false;
oLevel._alpha = 0;
oLines._alpha = 0;
oScore._alpha = 0;
tLevel._alpha = 0;
tLines._alpha = 0;
tScore._alpha = 0;
nS._alpha = 0;
var fadetime = 0;
gOver = false;
game._visible = false;
btnNew._visible = false;
onEnterFrame = function () {
if (tetris) {
if (!hasShape) {
statsBox._visible = true;
currentShape = Math.round(Math.random() * 6);
newShape(currentShape);
nextShape = Math.round(Math.random() * 6);
showNextShape(nextShape);
}
fall();
leftRight();
}
if (breakout) {
control();
ballMove();
breakoutLogic();
}
if (fading) {
fade();
}
if (anim) {
animate(left);
}
};
newGame = function () {
tetris = true;
breakout = false;
gNum = 0;
hasShape = false;
timer = 0;
prevInterval = 30;
interval = 30;
moveTimer = 0;
rotTimer = 0;
num = 0;
rot = 0;
score = 0;
level = 1;
lines = 0;
bNum = 0;
reqLines = 2;
xp._width = 0;
anim = false;
left = 0;
bounce = false;
levelLines = 0;
stats = "0 / 2";
time = 0;
MILI = 0;
gOver = false;
};
breakoutLogic = function () {
MILI--;
if (MILI == 90) {
attachMovie("countd", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 73;
_root["single" + gNum]._y = 276;
gNum++;
}
if ((MILI % 30) == 0) {
time = MILI / 30;
}
if (ball._y > 545) {
ball._alpha = ball._alpha - 10;
}
if ((MILI == 0) || (ball._y > 600)) {
anim = true;
left = 1;
breakout = false;
convertBack();
}
i = 0;
while (i < 150) {
if (bSlot[i]) {
break;
}
if (i == 149) {
anim = true;
left = 1;
breakout = false;
convertBack();
score = score + 10;
attachMovie("cleared", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 73;
_root["single" + gNum]._y = 276;
gNum++;
}
i++;
}
};
fade = function () {
if (fadetime != 10) {
grid._alpha = grid._alpha + 10;
gO._alpha = gO._alpha + 10;
btnSound._alpha = btnSound._alpha + 10;
btnMenu._alpha = btnMenu._alpha + 10;
xBar._alpha = xBar._alpha + 10;
xp._alpha = xp._alpha + 10;
oLevel._alpha = oLevel._alpha + 10;
oLines._alpha = oLines._alpha + 10;
oScore._alpha = oScore._alpha + 10;
tLevel._alpha = tLevel._alpha + 10;
tLines._alpha = tLines._alpha + 10;
tScore._alpha = tScore._alpha + 10;
nS._alpha = nS._alpha + 10;
} else {
fading = false;
tetris = true;
}
fadetime++;
};
ballMove = function () {
ball._x = ball._x + xBall;
ball._y = ball._y + yBall;
if (ball.hitTest(paddle)) {
yBall = yBall * -1;
}
if (ball._x < 25) {
ball._x = 25;
xBall = xBall * -1;
}
if (ball._x > 315) {
ball._x = 315;
xBall = xBall * -1;
}
if (ball._y < 75) {
ball._y = 75;
yBall = yBall * -1;
}
i = 0;
while (i < 150) {
if (bSlot[i]) {
if (ball.hitTest(_root[bNames[i]])) {
score++;
_root[bNames[i]].removeMovieClip();
bSlot[i] = false;
bColors[i] = "";
bNames[i] = "";
}
}
i++;
}
};
control = function () {
if (Key.isDown(37) && (paddle._x > 25)) {
paddle._x = paddle._x - 8;
}
if (Key.isDown(39) && (paddle._x < 255)) {
paddle._x = paddle._x + 8;
}
if (paddle._x < 25) {
paddle._x = 25;
}
if (paddle._x > 255) {
paddle._x = 255;
}
};
leftRight = function () {
moveTimer++;
rotTimer++;
if (((((((((Key.isDown(37) && (moveTimer > 3)) && (b1._x != 25)) && (b2._x != 25)) && (b3._x != 25)) && (b4._x != 25)) && (!slot[occSlot[0] - 1])) && (!slot[occSlot[1] - 1])) && (!slot[occSlot[2] - 1])) && (!slot[occSlot[3] - 1])) {
b1._x = b1._x - 30;
b2._x = b2._x - 30;
b3._x = b3._x - 30;
b4._x = b4._x - 30;
i = 0;
while (i < 4) {
occSlot[i]--;
i++;
}
moveTimer = 0;
}
if (((((((((Key.isDown(39) && (moveTimer > 3)) && (b1._x != 295)) && (b2._x != 295)) && (b3._x != 295)) && (b4._x != 295)) && (!slot[occSlot[0] + 1])) && (!slot[occSlot[1] + 1])) && (!slot[occSlot[2] + 1])) && (!slot[occSlot[3] + 1])) {
b1._x = b1._x + 30;
b2._x = b2._x + 30;
b3._x = b3._x + 30;
b4._x = b4._x + 30;
i = 0;
while (i < 4) {
occSlot[i]++;
i++;
}
moveTimer = 0;
}
if (Key.isDown(40)) {
if (interval > 3) {
prevInterval = interval;
}
interval = 3;
} else {
interval = prevInterval;
}
if (Key.isDown(38) && (rotTimer > 5)) {
rotate();
rotTimer = 0;
}
};
fall = function (shape) {
timer++;
if (timer > interval) {
if (((((((((occSlot[0] - 10) >= 0) && ((occSlot[1] - 10) >= 0)) && ((occSlot[2] - 10) >= 0)) && ((occSlot[3] - 10) >= 0)) && (!slot[occSlot[0] - 10])) && (!slot[occSlot[1] - 10])) && (!slot[occSlot[2] - 10])) && (!slot[occSlot[3] - 10])) {
b1._y = b1._y + 30;
b2._y = b2._y + 30;
b3._y = b3._y + 30;
b4._y = b4._y + 30;
i = 0;
while (i < 4) {
occSlot[i] = occSlot[i] - 10;
i++;
}
timer = 0;
} else {
freeze();
}
if (interval == 3) {
score++;
}
}
};
rotate = function () {
if (currentShape == 1) {
if (rot == 0) {
if (((((occSlot[0] - 9) >= 0) && (!slot[occSlot[0] - 9])) && (((occSlot[2] + 9) <= 149) && (!slot[occSlot[2] + 9]))) && (((occSlot[3] + 18) <= 149) && (!slot[occSlot[3] + 18]))) {
b1._x = b1._x + 30;
b1._y = b1._y + 30;
b3._x = b3._x - 30;
b3._y = b3._y - 30;
b4._x = b4._x - 60;
b4._y = b4._y - 60;
occSlot[0] = occSlot[0] - 9;
occSlot[2] = occSlot[2] + 9;
occSlot[3] = occSlot[3] + 18;
rot = 1;
}
} else if (rot == 1) {
if ((((((((occSlot[0] + 9) <= 149) && (!slot[occSlot[0] + 9])) && (((occSlot[2] - 9) >= 0) && (!slot[occSlot[2] - 9]))) && (((occSlot[3] - 18) >= 0) && (!slot[occSlot[3] - 18]))) && (b1._x != 25)) && (b1._x != 265)) && (b1._x != 295)) {
b1._x = b1._x - 30;
b1._y = b1._y - 30;
b3._x = b3._x + 30;
b3._y = b3._y + 30;
b4._x = b4._x + 60;
b4._y = b4._y + 60;
occSlot[0] = occSlot[0] + 9;
occSlot[2] = occSlot[2] - 9;
occSlot[3] = occSlot[3] - 18;
rot = 0;
}
}
} else if (currentShape == 2) {
if (rot == 0) {
if (((((occSlot[0] - 10) >= 0) && (!slot[occSlot[0] - 10])) && (((occSlot[2] - 11) >= 0) && (!slot[occSlot[2] - 11]))) && (((occSlot[3] + 19) <= 149) && (!slot[occSlot[3] + 19]))) {
b1._y = b1._y + 30;
b3._x = b3._x - 30;
b3._y = b3._y + 30;
b4._x = b4._x - 30;
b4._y = b4._y - 60;
occSlot[0] = occSlot[0] - 10;
occSlot[2] = occSlot[2] - 11;
occSlot[3] = occSlot[3] + 19;
rot = 1;
}
} else if (rot == 1) {
if ((((((occSlot[0] + 10) >= 0) && (!slot[occSlot[0] + 10])) && (((occSlot[2] + 11) <= 149) && (!slot[occSlot[2] + 11]))) && (((occSlot[3] - 1) >= 0) && (!slot[occSlot[3] - 1]))) && (b2._x != 295)) {
b1._y = b1._y - 30;
b3._x = b3._x + 30;
b3._y = b3._y - 30;
b4._x = b4._x - 30;
occSlot[0] = occSlot[0] + 10;
occSlot[2] = occSlot[2] + 11;
occSlot[3] = occSlot[3] - 1;
rot = 2;
}
} else if (rot == 2) {
if ((((occSlot[1] - 11) >= 0) && (!slot[occSlot[1] - 11])) && (((occSlot[2] + 9) <= 149) && (!slot[occSlot[2] + 9]))) {
b2._x = b2._x - 30;
b2._y = b2._y + 30;
b3._x = b3._x - 30;
b3._y = b3._y - 30;
occSlot[1] = occSlot[1] - 11;
occSlot[2] = occSlot[2] + 9;
rot = 3;
}
} else if (rot == 3) {
if ((((((occSlot[1] + 11) <= 149) && (!slot[occSlot[1] + 11])) && (((occSlot[2] - 9) >= 0) && (!slot[occSlot[2] - 9]))) && (((occSlot[3] - 18) >= 0) && (!slot[occSlot[3] - 18]))) && (b3._x != 295)) {
b2._x = b2._x + 30;
b2._y = b2._y - 30;
b3._x = b3._x + 30;
b3._y = b3._y + 30;
b4._x = b4._x + 60;
b4._y = b4._y + 60;
occSlot[1] = occSlot[1] + 11;
occSlot[2] = occSlot[2] - 9;
occSlot[3] = occSlot[3] - 18;
rot = 0;
}
}
} else if (currentShape == 3) {
if (rot == 0) {
if ((((occSlot[2] - 11) >= 0) && (!slot[occSlot[2] - 11])) && (((occSlot[3] - 9) >= 0) && (!slot[occSlot[3] - 9]))) {
b3._x = b3._x - 30;
b3._y = b3._y + 30;
b4._x = b4._x + 30;
b4._y = b4._y + 30;
occSlot[2] = occSlot[2] - 11;
occSlot[3] = occSlot[3] - 9;
rot = 1;
}
} else if (rot == 1) {
if ((((((occSlot[0] - 10) >= 0) && (!slot[occSlot[0] - 10])) && (((occSlot[1] - 9) >= 0) && (!slot[occSlot[1] - 9]))) && (((occSlot[3] + 21) <= 149) && (!slot[occSlot[3] + 21]))) && (b2._x != 295)) {
b1._y = b1._y + 30;
b2._x = b2._x + 30;
b2._y = b2._y + 30;
b4._y = b4._y - 60;
b4._x = b4._x + 30;
occSlot[0] = occSlot[0] - 10;
occSlot[1] = occSlot[1] - 9;
occSlot[3] = occSlot[3] + 21;
rot = 2;
}
} else if (rot == 2) {
if (((((occSlot[1] + 8) <= 149) && (!slot[occSlot[1] + 8])) && (((occSlot[2] - 11) >= 0) && (!slot[occSlot[2] - 11]))) && (((occSlot[3] - 21) >= 0) && (!slot[occSlot[3] - 21]))) {
b2._x = b2._x - 60;
b2._y = b2._y - 30;
b3._x = b3._x - 30;
b3._y = b3._y + 30;
b4._x = b4._x - 30;
b4._y = b4._y + 60;
occSlot[1] = occSlot[1] + 8;
occSlot[2] = occSlot[2] - 11;
occSlot[3] = occSlot[3] - 21;
rot = 3;
}
} else if (rot == 3) {
if (((((((occSlot[0] + 10) <= 149) && (!slot[occSlot[0] + 10])) && (((occSlot[1] + 1) <= 149) && (!slot[occSlot[1] + 1]))) && (((occSlot[2] + 22) <= 149) && (!slot[occSlot[2] + 22]))) && (((occSlot[3] + 9) <= 149) && (!slot[occSlot[3] + 9]))) && (b4._x != 295)) {
b1._y = b1._y - 30;
b2._x = b2._x + 30;
b3._x = b3._x + 60;
b3._y = b3._y - 60;
b4._x = b4._x - 30;
b4._y = b4._y - 30;
occSlot[0] = occSlot[0] + 10;
occSlot[1] = occSlot[1] + 1;
occSlot[2] = occSlot[2] + 22;
occSlot[3] = occSlot[3] + 9;
rot = 0;
}
}
} else if (currentShape == 4) {
if (rot == 0) {
if (((occSlot[2] + 9) <= 149) && (!slot[occSlot[2] + 9])) {
b3._x = b3._x - 30;
b3._y = b3._y - 30;
occSlot[2] = occSlot[2] + 9;
rot = 1;
}
} else if (rot == 1) {
if ((((occSlot[3] + 11) <= 159) && (!slot[occSlot[3] + 11])) && (b2._x != 295)) {
b4._x = b4._x + 30;
b4._y = b4._y - 30;
occSlot[3] = occSlot[3] + 11;
rot = 2;
}
} else if (rot == 2) {
if (((occSlot[0] - 9) >= 0) && (!slot[occSlot[0] - 9])) {
b1._x = b1._x + 30;
b1._y = b1._y + 30;
occSlot[0] = occSlot[0] - 9;
rot = 3;
}
} else if (rot == 3) {
if ((((((occSlot[0] + 9) <= 149) && (!slot[occSlot[0] + 9])) && (((occSlot[2] - 9) >= 0) && (!slot[occSlot[2] - 9]))) && (((occSlot[3] - 11) >= 0) && (!slot[occSlot[3] - 11]))) && (b1._x != 25)) {
b1._x = b1._x - 30;
b1._y = b1._y - 30;
b3._x = b3._x + 30;
b3._y = b3._y + 30;
b4._x = b4._x - 30;
b4._y = b4._y + 30;
occSlot[0] = occSlot[0] + 9;
occSlot[2] = occSlot[2] - 9;
occSlot[3] = occSlot[3] - 11;
rot = 0;
}
}
} else if (currentShape == 5) {
if (rot == 0) {
if ((((occSlot[0] + 2) <= 149) && (!slot[occSlot[0] + 2])) && (((occSlot[3] + 20) <= 149) && (!slot[occSlot[3] + 20]))) {
b1._x = b1._x + 60;
b4._y = b4._y - 60;
occSlot[0] = occSlot[0] + 2;
occSlot[3] = occSlot[3] + 20;
rot = 1;
}
} else if (rot == 1) {
if (((((occSlot[0] - 2) >= 0) && (!slot[occSlot[0] - 2])) && (((occSlot[3] - 20) >= 0) && (!slot[occSlot[3] - 20]))) && (b2._x != 25)) {
b1._x = b1._x - 60;
b4._y = b4._y + 60;
occSlot[0] = occSlot[0] - 2;
occSlot[3] = occSlot[3] - 20;
rot = 0;
}
}
} else if (currentShape == 6) {
if (rot == 0) {
if ((((occSlot[0] + 2) <= 149) && (!slot[occSlot[0] + 2])) && (((occSlot[1] + 20) <= 149) && (!slot[occSlot[1] + 20]))) {
b1._x = b1._x + 60;
b2._y = b2._y - 60;
occSlot[0] = occSlot[0] + 2;
occSlot[1] = occSlot[1] + 20;
rot = 1;
}
} else if (rot == 1) {
if (((((occSlot[0] - 2) >= 0) && (!slot[occSlot[0] - 2])) && (((occSlot[1] - 20) >= 0) && (!slot[occSlot[1] - 20]))) && (b3._x != 25)) {
b1._x = b1._x - 60;
b2._y = b2._y + 60;
occSlot[0] = occSlot[0] - 2;
occSlot[1] = occSlot[1] - 20;
rot = 0;
}
}
}
};
freeze = function () {
i = 0;
while (i < 4) {
slot[occSlot[i]] = true;
attachMovie("block", "block" + num, _root.getNextHighestDepth());
names[occSlot[i]] = "block" + num;
colors[occSlot[i]] = FCOLOR;
_root["block" + num]._x = _root["b" + (i + 1)]._x;
_root["block" + num]._y = _root["b" + (i + 1)]._y;
var _local2 = new Color(_root["block" + num]);
_local2.setRGB(FCOLOR);
num++;
i++;
}
score++;
lineCheck();
currentShape = nextShape;
newShape(currentShape);
nextShape = Math.round(Math.random() * 6);
showNextShape(nextShape);
};
newShape = function (shape) {
if (shape == 0) {
occSlot[0] = 144;
occSlot[1] = 145;
occSlot[2] = 134;
occSlot[3] = 135;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 255;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 145;
b1._y = 75;
b2._x = 175;
b2._y = 75;
b3._x = 145;
b3._y = 105;
b4._x = 175;
b4._y = 105;
} else if (shape == 1) {
occSlot[0] = 143;
occSlot[1] = 144;
occSlot[2] = 145;
occSlot[3] = 146;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 65280;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 115;
b1._y = 75;
b2._x = 145;
b2._y = 75;
b3._x = 175;
b3._y = 75;
b4._x = 205;
b4._y = 75;
} else if (shape == 2) {
occSlot[0] = 143;
occSlot[1] = 144;
occSlot[2] = 145;
occSlot[3] = 135;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 16711680 /* 0xFF0000 */;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 115;
b1._y = 75;
b2._x = 145;
b2._y = 75;
b3._x = 175;
b3._y = 75;
b4._x = 175;
b4._y = 105;
} else if (shape == 3) {
occSlot[0] = 143;
occSlot[1] = 144;
occSlot[2] = 145;
occSlot[3] = 133;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 16776960 /* 0xFFFF00 */;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 115;
b1._y = 75;
b2._x = 145;
b2._y = 75;
b3._x = 175;
b3._y = 75;
b4._x = 115;
b4._y = 105;
} else if (shape == 4) {
occSlot[0] = 143;
occSlot[1] = 144;
occSlot[2] = 145;
occSlot[3] = 134;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 65535;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 115;
b1._y = 75;
b2._x = 145;
b2._y = 75;
b3._x = 175;
b3._y = 75;
b4._x = 145;
b4._y = 105;
} else if (shape == 5) {
occSlot[0] = 143;
occSlot[1] = 144;
occSlot[2] = 134;
occSlot[3] = 135;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 16711935 /* 0xFF00FF */;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 115;
b1._y = 75;
b2._x = 145;
b2._y = 75;
b3._x = 145;
b3._y = 105;
b4._x = 175;
b4._y = 105;
} else if (shape == 6) {
occSlot[0] = 133;
occSlot[1] = 134;
occSlot[2] = 144;
occSlot[3] = 145;
i = 1;
while (i <= 4) {
var _local1 = new Color("b" + i);
FCOLOR = 10027263 /* 0x9900FF */;
_local1.setRGB(FCOLOR);
i++;
}
b1._x = 115;
b1._y = 105;
b2._x = 145;
b2._y = 105;
b3._x = 145;
b3._y = 75;
b4._x = 175;
b4._y = 75;
}
i = 0;
while (i < 4) {
if (slot[occSlot[i]]) {
game._visible = true;
btnNew._visible = true;
tetris = false;
gOver = true;
break;
}
i++;
}
rot = 0;
timer = 0;
hasShape = true;
};
showNextShape = function (shape) {
if (shape == 0) {
shapeO._x = 380;
shapeO._y = 90;
} else {
shapeO._x = -500;
shapeO._y = -500;
}
if (shape == 1) {
shapeI._x = 350;
shapeI._y = 105;
} else {
shapeI._x = -500;
shapeI._y = -500;
}
if (shape == 2) {
shapeJ._x = 365;
shapeJ._y = 90;
} else {
shapeJ._x = -500;
shapeJ._y = -500;
}
if (shape == 3) {
shapeL._x = 365;
shapeL._y = 90;
} else {
shapeL._x = -500;
shapeL._y = -500;
}
if (shape == 4) {
shapeT._x = 365;
shapeT._y = 90;
} else {
shapeT._x = -500;
shapeT._y = -500;
}
if (shape == 5) {
shapeZ._x = 365;
shapeZ._y = 90;
} else {
shapeZ._x = -500;
shapeZ._y = -500;
}
if (shape == 6) {
shapeS._x = 365;
shapeS._y = 90;
} else {
shapeS._x = -500;
shapeS._y = -500;
}
};
lineCheck = function () {
var _local2 = 0;
i = 0;
while (i < 15) {
x = i * 10;
while (x < ((i * 10) + 10)) {
if (!slot[x]) {
break;
}
if (x == ((i * 10) + 9)) {
t = i * 10;
while (t < ((i * 10) + 10)) {
_root[names[t]].removeMovieClip();
slot[t] = false;
t++;
}
_local2++;
gravity(i);
i = -1;
lines++;
levelLines++;
xp._width = xp._width + (300 / reqLines);
score = score + 10;
if (levelLines == reqLines) {
level++;
levelLines = 0;
reqLines++;
xp._width = 0;
if (interval > 8) {
interval = interval - 5;
}
MILI = (level * 30) + 240;
time = MILI / 30;
tetris = false;
}
stats = (levelLines + " / ") + reqLines;
}
x++;
}
i++;
}
if (tetris) {
if (_local2 == 1) {
attachMovie("single", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 115;
_root["single" + gNum]._y = 314;
gNum++;
}
if (_local2 == 2) {
attachMovie("double", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 105;
_root["single" + gNum]._y = 309;
gNum++;
}
if (_local2 == 3) {
attachMovie("triple", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 100;
_root["single" + gNum]._y = 309;
gNum++;
}
if (_local2 == 4) {
attachMovie("tetris", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 73;
_root["single" + gNum]._y = 276;
gNum++;
}
}
if ((!tetris) && (!gOver)) {
a = 0;
while (a < 150) {
if (slot[a]) {
break;
}
if (a == 149) {
tetris = true;
score = score + 100;
attachMovie("plus", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 73;
_root["single" + gNum]._y = 276;
gNum++;
}
a++;
}
if ((!tetris) && (!gOver)) {
attachMovie("levelup", "single" + gNum, _root.getNextHighestDepth());
_root["single" + gNum]._x = 73;
_root["single" + gNum]._y = 276;
gNum++;
b1._x = -500;
b2._x = -500;
b3._x = -500;
b4._x = -500;
left = 0;
convert();
anim = true;
}
}
};
gravity = function (line) {
t = (line * 10) + 10;
while (t < 150) {
if (slot[t]) {
_root[names[t]]._y = _root[names[t]]._y + 30;
slot[t] = false;
names[t - 10] = names[t];
names[t] = "";
slot[t - 10] = true;
colors[t - 10] = colors[t];
colors[t] = "";
}
t++;
}
};
btnMenu.onRelease = function () {
if (tetris || (gOver)) {
anim = true;
left = 2;
}
};
btnSound.onRelease = function () {
if (hasSound) {
stopAllSounds();
redx._visible = true;
hasSound = false;
} else {
var _local1 = new Sound();
_local1.attachSound("mus");
_local1.start(0, 9999);
redx._visible = false;
hasSound = true;
}
};
convert = function () {
q = 0;
while (q < 15) {
w = 0;
while (w < 10) {
if (slot[(q * 10) + w]) {
bSlot[(150 - ((q + 1) * 10)) + w] = true;
attachMovie("block", "brick" + bNum, _root.getNextHighestDepth());
_root["brick" + bNum]._x = ((w * 30) + 25) - 600;
_root["brick" + bNum]._y = (q * 30) + 75;
bNames[(150 - ((q + 1) * 10)) + w] = "brick" + bNum;
var _local2 = new Color("brick" + bNum);
COLOR = colors[(q * 10) + w];
bColors[(150 - ((q + 1) * 10)) + w] = COLOR;
_local2.setRGB(COLOR);
bNum++;
}
w++;
}
q++;
}
};
convertBack = function () {
q = 0;
while (q < 15) {
w = 0;
while (w < 10) {
if (bSlot[(q * 10) + w]) {
slot[(150 - ((q + 1) * 10)) + w] = true;
attachMovie("block", "block" + num, _root.getNextHighestDepth());
_root["block" + num]._x = ((w * 30) + 25) + 600;
_root["block" + num]._y = (q * 30) + 75;
names[(150 - ((q + 1) * 10)) + w] = "block" + num;
var _local2 = new Color("block" + num);
COLOR = bColors[(q * 10) + w];
colors[(150 - ((q + 1) * 10)) + w] = COLOR;
_local2.setRGB(COLOR);
num++;
}
w++;
}
q++;
}
_root.single0.removeMovieClip();
};
removeTetris = function () {
i = 0;
while (i < 150) {
if (slot[i]) {
_root[names[i]].removeMovieClip();
names[i] = "";
colors[i] = "";
slot[i] = false;
}
i++;
}
i = 0;
while (i <= gNum) {
_root["single" + i].removeMovieClip();
i++;
}
gNum = 0;
num = 0;
};
removeBreakout = function () {
i = 0;
while (i < 150) {
if (bSlot[i]) {
_root[bNames[i]].removeMovieClip();
bNames[i] = "";
bSlot[i] = false;
}
i++;
}
i = 0;
while (i <= gNum) {
_root["single" + i].removeMovieClip();
i++;
}
gNum = 0;
bNum = 0;
};
animate = function (left) {
if (left == 0) {
if (bg2._x < -50) {
bg2._x = bg2._x + 10;
grid._x = grid._x + 10;
gO._x = gO._x + 10;
nS._x = nS._x + 10;
shapeO._x = shapeO._x + 10;
shapeI._x = shapeI._x + 10;
shapeJ._x = shapeJ._x + 10;
shapeL._x = shapeL._x + 10;
shapeT._x = shapeT._x + 10;
shapeZ._x = shapeZ._x + 10;
shapeS._x = shapeS._x + 10;
xBar._x = xBar._x + 10;
xp._x = xp._x + 10;
statsBox._x = statsBox._x + 10;
paddle._x = paddle._x + 10;
b1._x = b1._x + 10;
b2._x = b2._x + 10;
b3._x = b3._x + 10;
b4._x = b4._x + 10;
ball._x = ball._x + 10;
if (num < 150) {
i = 0;
while (i <= num) {
_root["block" + i]._x = _root["block" + i]._x + 10;
i++;
}
} else {
i = 0;
while (i < 150) {
if (slot[i]) {
_root[names[i]]._x = _root[names[i]]._x + 10;
}
i++;
}
}
if (bNum < 150) {
i = 0;
while (i <= bNum) {
_root["brick" + i]._x = _root["brick" + i]._x + 10;
i++;
}
} else {
i = 0;
while (i < 150) {
if (bSlot[i]) {
_root[bNames[i]]._x = _root[bNames[i]]._x + 10;
}
i++;
}
}
grid2._x = grid2._x + 10;
ovalHits._x = ovalHits._x + 10;
hBox._x = hBox._x + 10;
pad._x = pad._x + 10;
} else if (bounce == false) {
if (bg2._x < -25) {
bg2._x = bg2._x + 5;
nS._x = nS._x + 5;
xBar._x = xBar._x + 5;
xp._x = xp._x + 5;
statsBox._x = statsBox._x + 5;
paddle._x = paddle._x + 5;
grid2._x = grid2._x + 5;
pad._x = pad._x + 5;
ball._x = ball._x + 5;
if (bNum < 150) {
i = 0;
while (i <= bNum) {
_root["brick" + i]._x = _root["brick" + i]._x + 5;
i++;
}
} else {
i = 0;
while (i < 150) {
if (bSlot[i]) {
_root[bNames[i]]._x = _root[bNames[i]]._x + 5;
}
i++;
}
}
} else {
bounce = true;
}
} else if (bg2._x > -50) {
bg2._x = bg2._x - 5;
nS._x = nS._x - 5;
xBar._x = xBar._x - 5;
xp._x = xp._x - 5;
statsBox._x = statsBox._x - 5;
paddle._x = paddle._x - 5;
grid2._x = grid2._x - 5;
pad._x = pad._x - 5;
ball._x = ball._x - 5;
if (bNum < 150) {
i = 0;
while (i <= bNum) {
_root["brick" + i]._x = _root["brick" + i]._x - 5;
i++;
}
} else {
i = 0;
while (i < 150) {
if (bSlot[i]) {
_root[bNames[i]]._x = _root[bNames[i]]._x - 5;
}
i++;
}
}
} else {
bounce = false;
anim = false;
breakout = true;
xBall = (level * 2) + (Math.random() * 8);
if (xBall > 20) {
xBall = 20;
}
yBall = (level * 2) + (Math.random() * 5);
if (yBall > 9) {
yBall = 9;
}
var _local2 = Math.random();
if (_local2 < 0.5) {
xBall = xBall * -1;
}
removeTetris();
}
} else if (left == 1) {
if (bg2._x > -650) {
bg2._x = bg2._x - 10;
grid._x = grid._x - 10;
gO._x = gO._x - 10;
nS._x = nS._x - 10;
shapeO._x = shapeO._x - 10;
shapeI._x = shapeI._x - 10;
shapeJ._x = shapeJ._x - 10;
shapeL._x = shapeL._x - 10;
shapeT._x = shapeT._x - 10;
shapeZ._x = shapeZ._x - 10;
shapeS._x = shapeS._x - 10;
xBar._x = xBar._x - 10;
xp._x = xp._x - 10;
statsBox._x = statsBox._x - 10;
paddle._x = paddle._x - 10;
b1._x = b1._x - 10;
b2._x = b2._x - 10;
b3._x = b3._x - 10;
b4._x = b4._x - 10;
ball._x = ball._x - 10;
if (num < 150) {
i = 0;
while (i <= num) {
_root["block" + i]._x = _root["block" + i]._x - 10;
i++;
}
} else {
i = 0;
while (i < 150) {
if (slot[i]) {
_root[names[i]]._x = _root[names[i]]._x - 10;
}
i++;
}
}
if (bNum < 150) {
i = 0;
while (i <= bNum) {
_root["brick" + i]._x = _root["brick" + i]._x - 10;
i++;
}
} else {
i = 0;
while (i < 150) {
if (bSlot[i]) {
_root[bNames[i]]._x = _root[bNames[i]]._x - 10;
}
i++;
}
}
grid2._x = grid2._x - 10;
ovalHits._x = ovalHits._x - 10;
hBox._x = hBox._x - 10;
pad._x = pad._x - 10;
} else if (bounce == false) {
if (bg2._x > -675) {
bg2._x = bg2._x - 5;
grid._x = grid._x - 5;
gO._x = gO._x - 5;
nS._x = nS._x - 5;
shapeO._x = shapeO._x - 5;
shapeI._x = shapeI._x - 5;
shapeJ._x = shapeJ._x - 5;
shapeL._x = shapeL._x - 5;
shapeT._x = shapeT._x - 5;
shapeZ._x = shapeZ._x - 5;
shapeS._x = shapeS._x - 5;
xBar._x = xBar._x - 5;
xp._x = xp._x - 5;
statsBox._x = statsBox._x - 5;
b1._x = b1._x - 5;
b2._x = b2._x - 5;
b3._x = b3._x - 5;
b4._x = b4._x - 5;
if (num < 150) {
i = 0;
while (i <= num) {
_root["block" + i]._x = _root["block" + i]._x - 5;
i++;
}
} else {
i = 0;
while (i < 150) {
if (slot[i]) {
_root[names[i]]._x = _root[names[i]]._x - 5;
}
i++;
}
}
} else {
bounce = true;
}
} else if (bg2._x < -650) {
bg2._x = bg2._x + 5;
grid._x = grid._x + 5;
gO._x = gO._x + 5;
nS._x = nS._x + 5;
shapeO._x = shapeO._x + 5;
shapeI._x = shapeI._x + 5;
shapeJ._x = shapeJ._x + 5;
shapeL._x = shapeL._x + 5;
shapeT._x = shapeT._x + 5;
shapeZ._x = shapeZ._x + 5;
shapeS._x = shapeS._x + 5;
xBar._x = xBar._x + 5;
xp._x = xp._x + 5;
statsBox._x = statsBox._x + 5;
b1._x = b1._x + 5;
b2._x = b2._x + 5;
b3._x = b3._x + 5;
b4._x = b4._x + 5;
if (num < 150) {
i = 0;
while (i <= num) {
_root["block" + i]._x = _root["block" + i]._x + 5;
i++;
}
} else {
i = 0;
while (i < 150) {
if (slot[i]) {
_root[names[i]]._x = _root[names[i]]._x + 5;
}
i++;
}
}
} else {
bounce = false;
anim = false;
tetris = true;
removeBreakout();
paddle._x = -460;
ball._x = -430;
ball._y = 520;
ball._alpha = 100;
}
} else if (left == 2) {
if (bg2._y > -575) {
bg2._y = bg2._y - 10;
grid._y = grid._y - 10;
gO._y = gO._y - 10;
nS._y = nS._y - 10;
shapeO._y = shapeO._y - 10;
shapeI._y = shapeI._y - 10;
shapeJ._y = shapeJ._y - 10;
shapeL._y = shapeL._y - 10;
shapeT._y = shapeT._y - 10;
shapeZ._y = shapeZ._y - 10;
shapeS._y = shapeS._y - 10;
xBar._y = xBar._y - 10;
xp._y = xp._y - 10;
statsBox._y = statsBox._y - 10;
b1._y = b1._y - 10;
b2._y = b2._y - 10;
b3._y = b3._y - 10;
b4._y = b4._y - 10;
ball._y = ball._y - 10;
oLevel._y = oLevel._y - 10;
oLines._y = oLines._y - 10;
oScore._y = oScore._y - 10;
ovalHits._y = ovalHits._y - 10;
tLevel._y = tLevel._y - 10;
tLines._y = tLines._y - 10;
tScore._y = tScore._y - 10;
btnMenu._y = btnMenu._y - 10;
btnSound._y = btnSound._y - 10;
redx._y = redx._y - 10;
btnNew._y = btnNew._y - 10;
game._y = game._y - 10;
if (num < 150) {
i = 0;
while (i <= num) {
_root["block" + i]._y = _root["block" + i]._y - 10;
i++;
}
} else {
i = 0;
while (i < 150) {
if (slot[i]) {
_root[names[i]]._y = _root[names[i]]._y - 10;
}
i++;
}
}
} else if (bounce == false) {
if (bg2._y > -600) {
bg2._y = bg2._y - 5;
statsBox._y = statsBox._y - 5;
xp._y = xp._y - 5;
xBar._y = xBar._y - 5;
} else {
bounce = true;
}
} else {
i = 0;
while (i <= num) {
_root["block" + i].removeMovieClip();
i++;
}
i = 0;
while (i <= bNum) {
_root["brick" + i].removeMovieClip();
i++;
}
bounce = false;
anim = false;
gotoAndPlay (2);
}
}
};
btnNew.onRelease = function () {
btnNew._visible = false;
game._visible = false;
removeTetris();
newGame();
};
Frame 4
stop();
var fading = true;
var fadetime = 0;
var anim = false;
var bounce = false;
hS._alpha = 0;
btnBack._alpha = 0;
onEnterFrame = function () {
if (fading) {
fade();
}
if (anim) {
animate();
}
};
btnBack.onRelease = function () {
anim = true;
};
fade = function () {
if (fadetime != 10) {
btnBack._alpha = btnBack._alpha + 10;
hS._alpha = hS._alpha + 10;
} else {
fading = false;
}
fadetime++;
};
animate = function () {
if (bg._x < -50) {
bg._x = bg._x + 10;
hS._x = hS._x + 10;
btnBack._x = btnBack._x + 10;
} else if (bounce == false) {
if (bg._x < -25) {
bg._x = bg._x + 5;
hS._x = hS._x + 5;
btnBack._x = btnBack._x + 5;
} else {
bounce = true;
}
} else if (bg._x > -50) {
bg._x = bg._x - 5;
} else {
bounce = false;
anim = false;
gotoAndPlay (2);
}
};
Symbol 5 MovieClip [triple] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 1;
this._y = this._y - 1;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 8 MovieClip [double] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 1;
this._y = this._y - 1;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 15 MovieClip [countd] Frame 1
stop();
var timer = 30;
this.onEnterFrame = function () {
timer--;
if (timer == 0) {
gotoAndPlay (2);
}
};
Symbol 15 MovieClip [countd] Frame 2
stop();
var timer = 30;
this.onEnterFrame = function () {
timer--;
if (timer == 0) {
gotoAndPlay (3);
}
};
Symbol 15 MovieClip [countd] Frame 3
stop();
var timer = 30;
this.onEnterFrame = function () {
timer--;
if (timer == 0) {
_alpha = 0;
}
};
Symbol 19 MovieClip [plus] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 2;
this._y = this._y - 1;
this._width = this._width + 2;
this._x = this._x - 1;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 23 MovieClip [cleared] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 2;
this._y = this._y - 1;
this._height = this._height + 2;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 27 MovieClip [tetris] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 2;
this._y = this._y - 1;
this._width = this._width + 2;
this._x = this._x - 1;
this._height = this._height + 2;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 31 MovieClip [levelup] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 2;
this._y = this._y - 1;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 34 MovieClip [single] Frame 1
this.onEnterFrame = function () {
this._alpha = this._alpha - 1;
this._y = this._y - 1;
if (this._alpha == 0) {
this.removeMovieClip();
}
};
Symbol 140 MovieClip [__Packages.MochiAd] Frame 0
class MochiAd
{
function MochiAd () {
}
static function getVersion() {
return("2.7");
}
static function showPreGameAd(options) {
var _local26 = {clip:_root, ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:16747008, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function () {
this.clip.stop();
}, ad_finished:function () {
this.clip.play();
}, ad_failed:function () {
trace("[MochiAd] Couldn't load an ad, make sure that your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_loaded:function (width, height) {
}, ad_skipped:function () {
}, ad_progress:function (percent) {
}};
options = _parseOptions(options, _local26);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def") {
options.ad_started();
options.ad_finished();
return(undefined);
}
var clip = options.clip;
var _local22 = 11000;
var _local25 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
options.ad_failed();
options.ad_finished();
return(undefined);
}
options.ad_started();
var mc = clip._mochiad;
mc.onUnload = function () {
options.ad_finished();
};
var _local14 = _getRes(options);
var _local4 = _local14[0];
var _local13 = _local14[1];
mc._x = _local4 * 0.5;
mc._y = _local13 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk._x = _local4 * -0.5;
chk._y = _local13 * -0.5;
var _local6 = chk.createEmptyMovieClip("_mochiad_bar", 4);
if (options.no_progress_bar) {
_local6._visible = false;
delete options.no_progress_bar;
} else {
_local6._x = 10;
_local6._y = _local13 - 20;
}
var _local21 = options.color;
delete options.color;
var _local19 = options.background;
delete options.background;
var _local23 = options.outline;
delete options.outline;
var _local5 = _local6.createEmptyMovieClip("_outline", 1);
_local5.beginFill(_local19);
_local5.moveTo(0, 0);
_local5.lineTo(_local4 - 20, 0);
_local5.lineTo(_local4 - 20, 10);
_local5.lineTo(0, 10);
_local5.lineTo(0, 0);
_local5.endFill();
var _local3 = _local6.createEmptyMovieClip("_inside", 2);
_local3.beginFill(_local21);
_local3.moveTo(0, 0);
_local3.lineTo(_local4 - 20, 0);
_local3.lineTo(_local4 - 20, 10);
_local3.lineTo(0, 10);
_local3.lineTo(0, 0);
_local3.endFill();
_local3._xscale = 0;
var _local7 = _local6.createEmptyMovieClip("_outline", 3);
_local7.lineStyle(0, _local23, 100);
_local7.moveTo(0, 0);
_local7.lineTo(_local4 - 20, 0);
_local7.lineTo(_local4 - 20, 10);
_local7.lineTo(0, 10);
_local7.lineTo(0, 0);
chk.ad_msec = _local22;
chk.ad_timeout = _local25;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.regContLC = function (lc_name) {
mc._containerLCName = lc_name;
};
var sendHostProgress = false;
mc.lc.sendHostLoadProgress = function (lc_name) {
sendHostProgress = true;
};
mc.lc.adLoaded = options.ad_loaded;
mc.lc.adSkipped = options.ad_skipped;
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec;
};
mc.lc.rpc = function (callbackID, arg) {
MochiAd.rpc(clip, callbackID, arg);
};
mc.rpcTestFn = function (s) {
trace("[MOCHIAD rpcTestFn] " + s);
return(s);
};
chk.onEnterFrame = function () {
var _local6 = this._parent._parent;
var _local11 = this._parent._mochiad_ctr;
var _local5 = getTimer() - this.started;
var _local3 = false;
var _local4 = _local6.getBytesTotal();
var _local8 = _local6.getBytesLoaded();
var _local2 = (100 * _local8) / _local4;
var _local10 = (100 * _local5) / chk.ad_msec;
var _local9 = this._mochiad_bar._inside;
var _local13 = Math.min(100, Math.min(_local2 || 0, _local10));
_local13 = Math.max(this.last_pcnt, _local13);
this.last_pcnt = _local13;
_local9._xscale = _local13;
options.ad_progress(_local13);
if (sendHostProgress) {
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local2});
if (_local2 == 100) {
sendHostProgress = false;
}
}
if (!chk.showing) {
var _local7 = _local11.getBytesTotal();
if ((_local7 > 0) || (typeof(_local7) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if ((_local5 > chk.ad_timeout) && (_local2 == 100)) {
options.ad_failed();
_local3 = true;
}
}
if (_local5 > chk.ad_msec) {
_local3 = true;
}
if (((_local4 > 0) && (_local8 >= _local4)) && (_local3)) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
}
}
};
}
static function showClickAwayAd(options) {
var _local9 = {clip:_root, ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function () {
}, ad_finished:function () {
}, ad_loaded:function (width, height) {
}, ad_failed:function () {
trace("[MochiAd] Couldn't load an ad, make sure that your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function () {
}};
options = _parseOptions(options, _local9);
var clip = options.clip;
var _local8 = options.ad_timeout;
delete options.ad_timeout;
if (!load(options)) {
options.ad_failed();
options.ad_finished();
return(undefined);
}
options.ad_started();
var mc = clip._mochiad;
mc.onUnload = function () {
options.ad_finished();
};
var _local4 = _getRes(options);
var _local10 = _local4[0];
var _local7 = _local4[1];
mc._x = _local10 * 0.5;
mc._y = _local7 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_timeout = _local8;
chk.started = getTimer();
chk.showing = false;
mc.lc.adLoaded = options.ad_loaded;
mc.lc.adSkipped = options.ad_skipped;
mc.lc.rpc = function (callbackID, arg) {
MochiAd.rpc(clip, callbackID, arg);
};
mc.rpcTestFn = function (s) {
trace("[MOCHIAD rpcTestFn] " + s);
return(s);
};
var _local20 = false;
mc.lc.regContLC = function (lc_name) {
mc._containerLCName = lc_name;
};
chk.onEnterFrame = function () {
var _local5 = this._parent._mochiad_ctr;
var _local4 = getTimer() - this.started;
var _local2 = false;
if (!chk.showing) {
var _local3 = _local5.getBytesTotal();
if ((_local3 > 0) || (typeof(_local3) == "undefined")) {
_local2 = true;
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
options.ad_failed();
_local2 = true;
}
}
if (_local2) {
delete this.onEnterFrame;
}
};
}
static function showInterLevelAd(options) {
var _local13 = {clip:_root, ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function () {
this.clip.stop();
}, ad_finished:function () {
this.clip.play();
}, ad_failed:function () {
trace("[MochiAd] Couldn't load an ad, make sure that your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_loaded:function (width, height) {
}, ad_skipped:function () {
}};
options = _parseOptions(options, _local13);
var clip = options.clip;
var _local10 = 11000;
var _local12 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!load(options)) {
options.ad_failed();
options.ad_finished();
return(undefined);
}
options.ad_started();
var mc = clip._mochiad;
mc.onUnload = function () {
options.ad_finished();
};
var _local5 = _getRes(options);
var _local14 = _local5[0];
var _local11 = _local5[1];
mc._x = _local14 * 0.5;
mc._y = _local11 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_msec = _local10;
chk.ad_timeout = _local12;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adLoaded = options.ad_loaded;
mc.lc.adSkipped = options.ad_skipped;
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec - 250;
};
mc.lc.rpc = function (callbackID, arg) {
MochiAd.rpc(clip, callbackID, arg);
};
mc.rpcTestFn = function (s) {
trace("[MOCHIAD rpcTestFn] " + s);
return(s);
};
chk.onEnterFrame = function () {
var _local5 = this._parent._mochiad_ctr;
var _local4 = getTimer() - this.started;
var _local2 = false;
if (!chk.showing) {
var _local3 = _local5.getBytesTotal();
if ((_local3 > 0) || (typeof(_local3) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
options.ad_failed();
_local2 = true;
}
}
if (_local4 > chk.ad_msec) {
_local2 = true;
}
if (_local2) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
}
}
};
}
static function showPreloaderAd(options) {
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
showPreGameAd(options);
}
static function showTimedAd(options) {
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
showInterLevelAd(options);
}
static function _allowDomains(server) {
var _local1 = server.split("/")[2].split(":")[0];
if (System.security) {
if (System.security.allowDomain) {
System.security.allowDomain("*");
System.security.allowDomain(_local1);
}
if (System.security.allowInsecureDomain) {
System.security.allowInsecureDomain("*");
System.security.allowInsecureDomain(_local1);
}
}
return(_local1);
}
static function load(options) {
var _local13 = {clip:_root, server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = _parseOptions(options, _local13);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = getVersion();
var _local9 = options.clip;
if (!_isNetworkAvailable()) {
return(null);
}
if (_local9._mochiad_loaded) {
return(null);
}
var _local12 = options.depth;
delete options.depth;
var _local6 = _local9.createEmptyMovieClip("_mochiad", _local12);
var _local11 = _getRes(options);
options.res = (_local11[0] + "x") + _local11[1];
options.server = options.server + options.id;
delete options.id;
_local9._mochiad_loaded = true;
var _local4 = _local6.createEmptyMovieClip("_mochiad_ctr", 1);
for (var _local7 in options) {
_local4[_local7] = options[_local7];
}
var _local10 = _local4.server;
delete _local4.server;
var _local14 = _allowDomains(_local10);
_local6.onEnterFrame = function () {
if (this._mochiad_ctr._url != this._url) {
this.onEnterFrame = function () {
if (!this._mochiad_ctr) {
delete this.onEnterFrame;
MochiAd.unload(this._parent);
}
};
}
};
var _local5 = new LocalConnection();
var _local8 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local5.mc = _local6;
_local5.name = _local8;
_local5.hostname = _local14;
_local5.allowDomain = function (d) {
return(true);
};
_local5.allowInsecureDomain = _local5.allowDomain;
_local5.connect(_local8);
_local6.lc = _local5;
_local4.lc = _local8;
_local4.st = getTimer();
_local4.loadMovie(_local10 + ".swf", "POST");
return(_local6);
}
static function unload(clip) {
if (typeof(clip) == "undefined") {
clip = _root;
}
if (clip.clip && (clip.clip._mochiad)) {
clip = clip.clip;
}
if (!clip._mochiad) {
return(false);
}
if (clip._mochiad._containerLCName != undefined) {
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"unload"});
}
clip._mochiad.removeMovieClip();
delete clip._mochiad_loaded;
delete clip._mochiad;
return(true);
}
static function _isNetworkAvailable() {
if (System.security) {
var _local1 = System.security;
if (_local1.sandboxType == "localWithFile") {
return(false);
}
}
return(true);
}
static function _getRes(options) {
var _local3 = options.clip.getBounds();
var _local2 = 0;
var _local1 = 0;
if (typeof(options.res) != "undefined") {
var _local4 = options.res.split("x");
_local2 = parseFloat(_local4[0]);
_local1 = parseFloat(_local4[1]);
} else {
_local2 = _local3.xMax - _local3.xMin;
_local1 = _local3.yMax - _local3.yMin;
}
if ((_local2 == 0) || (_local1 == 0)) {
_local2 = Stage.width;
_local1 = Stage.height;
}
return([_local2, _local1]);
}
static function _parseOptions(options, defaults) {
var _local4 = {};
for (var _local8 in defaults) {
_local4[_local8] = defaults[_local8];
}
if (options) {
for (var _local8 in options) {
_local4[_local8] = options[_local8];
}
}
if (_root.mochiad_options) {
var _local5 = _root.mochiad_options.split("&");
var _local2 = 0;
while (_local2 < _local5.length) {
var _local3 = _local5[_local2].split("=");
_local4[unescape(_local3[0])] = unescape(_local3[1]);
_local2++;
}
}
if (_local4.id == "test") {
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
}
return(_local4);
}
static function rpc(clip, callbackID, arg) {
switch (arg.id) {
case "setValue" :
setValue(clip, arg.objectName, arg.value);
break;
case "getValue" :
var _local4 = getValue(clip, arg.objectName);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local4);
break;
case "runMethod" :
var _local3 = runMethod(clip, arg.method, arg.args);
clip._mochiad.lc.send(clip._mochiad._containerLCName, "rpcResult", callbackID, _local3);
break;
default :
trace("[mochiads rpc] unknown rpc id: " + arg.id);
}
}
static function setValue(base, objectName, value) {
var _local2 = objectName.split(".");
var _local1;
_local1 = 0;
while (_local1 < (_local2.length - 1)) {
if ((base[_local2[_local1]] == undefined) || (base[_local2[_local1]] == null)) {
return(undefined);
}
base = base[_local2[_local1]];
_local1++;
}
base[_local2[_local1]] = value;
}
static function getValue(base, objectName) {
var _local2 = objectName.split(".");
var _local1;
_local1 = 0;
while (_local1 < (_local2.length - 1)) {
if ((base[_local2[_local1]] == undefined) || (base[_local2[_local1]] == null)) {
return(undefined);
}
base = base[_local2[_local1]];
_local1++;
}
return(base[_local2[_local1]]);
}
static function runMethod(base, methodName, argsArray) {
var _local2 = methodName.split(".");
var _local1;
_local1 = 0;
while (_local1 < (_local2.length - 1)) {
if ((base[_local2[_local1]] == undefined) || (base[_local2[_local1]] == null)) {
return(undefined);
}
base = base[_local2[_local1]];
_local1++;
}
if (typeof(base[_local2[_local1]]) == "function") {
return(base[_local2[_local1]].apply(base, argsArray));
}
return(undefined);
}
}