Frame 1
_global.stage_mc = this;
_global.preloader = function () {
bytesTotal = _root.getBytesTotal();
bytesLoaded = _root.getBytesLoaded();
if (bytesLoaded >= bytesTotal) {
gotoAndStop ("start");
} else {
percent_mc.percentBar_mc._width = (bytesLoaded / bytesTotal) * 100;
gotoAndPlay ("preload");
}
};
_global.preloader2 = function () {
if (percent_mc.percentBar_mc._width >= 500) {
gotoAndStop ("start");
} else {
percent_mc.percentBar_mc._width = percent_mc.percentBar_mc._width + 5;
gotoAndPlay ("preload");
}
};
_global.preloader();
var MochiAd = {getVersion:function () {
return("2.5");
}, showPreGameAd:function (options) {
var _local3 = this;
var _local24 = {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 = MochiAd._parseOptions(options, _local24);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def") {
options.ad_started();
options.ad_finished();
return(undefined);
}
var clip = options.clip;
var _local20 = 11000;
var _local23 = options.ad_timeout;
delete options.ad_timeout;
var _local18 = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)) {
options.ad_failed();
options.ad_finished();
return(undefined);
}
options.ad_started();
var mc = clip._mochiad;
mc.onUnload = function () {
options.ad_finished();
};
var _local12 = MochiAd._getRes(options);
var _local10 = _local12[0];
var _local11 = _local12[1];
mc._x = _local10 * 0.5;
mc._y = _local11 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk._x = _local10 * -0.5;
chk._y = _local11 * -0.5;
var _local5 = chk.createEmptyMovieClip("_mochiad_bar", 4);
if (options.no_progress_bar) {
_local5._visible = false;
delete options.no_progress_bar;
} else {
_local5._x = 10;
_local5._y = _local11 - 20;
}
var _local19 = options.color;
delete options.color;
var _local16 = options.background;
delete options.background;
var _local21 = options.outline;
delete options.outline;
var _local4 = _local5.createEmptyMovieClip("_outline", 1);
_local4.beginFill(_local16);
_local4.moveTo(0, 0);
_local4.lineTo(_local10 - 20, 0);
_local4.lineTo(_local10 - 20, 10);
_local4.lineTo(0, 10);
_local4.lineTo(0, 0);
_local4.endFill();
var _local7 = _local5.createEmptyMovieClip("_inside", 2);
_local7.beginFill(_local19);
_local7.moveTo(0, 0);
_local7.lineTo(_local10 - 20, 0);
_local7.lineTo(_local10 - 20, 10);
_local7.lineTo(0, 10);
_local7.lineTo(0, 0);
_local7.endFill();
_local7._xscale = 0;
var _local6 = _local5.createEmptyMovieClip("_outline", 3);
_local6.lineStyle(0, _local21, 100);
_local6.moveTo(0, 0);
_local6.lineTo(_local10 - 20, 0);
_local6.lineTo(_local10 - 20, 10);
_local6.lineTo(0, 10);
_local6.lineTo(0, 0);
chk.ad_msec = _local20;
chk.ad_timeout = _local23;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = _local18;
chk.fadeFunction = function () {
var _local2 = this;
var _local3 = 100 * (1 - ((getTimer() - _local2.fadeout_start) / _local2.fadeout_time));
if (_local3 > 0) {
_local2._parent._alpha = _local3;
return(undefined);
}
var _local4 = _local2._parent._parent;
MochiAd.unload(_local4);
delete _local2.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 _local2 = this;
var _local7 = _local2._parent._parent;
var _local12 = _local2._parent._mochiad_ctr;
var _local5 = getTimer() - _local2.started;
var _local6 = false;
var _local4 = _local7.getBytesTotal();
var _local9 = _local7.getBytesLoaded();
var _local3 = (100 * _local9) / _local4;
var _local11 = (100 * _local5) / chk.ad_msec;
var _local10 = _local2._mochiad_bar._inside;
var _local14 = Math.min(100, Math.min(_local3 || 0, _local11));
_local14 = Math.max(_local2.last_pcnt, _local14);
_local2.last_pcnt = _local14;
_local10._xscale = _local14;
options.ad_progress(_local14);
if (sendHostProgress) {
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local3});
if (_local3 == 100) {
sendHostProgress = false;
}
}
if (!chk.showing) {
var _local8 = _local12.getBytesTotal();
if ((_local8 > 0) || (typeof(_local8) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if ((_local5 > chk.ad_timeout) && (_local3 == 100)) {
options.ad_failed();
_local6 = true;
}
}
if (_local5 > chk.ad_msec) {
_local6 = true;
}
if (((_local4 > 0) && (_local9 >= _local4)) && (_local6)) {
if (_local2.server_control) {
delete _local2.onEnterFrame;
return(undefined);
}
_local2.fadeout_start = getTimer();
_local2.onEnterFrame = chk.fadeFunction;
}
};
}, showClickAwayAd:function (options) {
var _local8 = {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 = MochiAd._parseOptions(options, _local8);
var clip = options.clip;
var _local7 = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.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 = MochiAd._getRes(options);
var _local9 = _local4[0];
var _local6 = _local4[1];
mc._x = _local9 * 0.5;
mc._y = _local6 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_timeout = _local7;
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 _local19 = 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;
}
};
}, showInterLevelAd:function (options) {
var _local3 = this;
var _local12 = {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 = MochiAd._parseOptions(options, _local12);
var clip = options.clip;
var _local9 = 11000;
var _local11 = options.ad_timeout;
delete options.ad_timeout;
var _local8 = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.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 = MochiAd._getRes(options);
var _local13 = _local5[0];
var _local10 = _local5[1];
mc._x = _local13 * 0.5;
mc._y = _local10 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_msec = _local9;
chk.ad_timeout = _local11;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = _local8;
chk.fadeFunction = function () {
var _local2 = this;
var _local3 = 100 * (1 - ((getTimer() - _local2.fadeout_start) / _local2.fadeout_time));
if (_local3 > 0) {
_local2._parent._alpha = _local3;
return(undefined);
}
var _local4 = _local2._parent._parent;
MochiAd.unload(_local4);
delete _local2.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 _local2 = this;
var _local6 = _local2._parent._mochiad_ctr;
var _local4 = getTimer() - _local2.started;
var _local3 = false;
if (!chk.showing) {
var _local5 = _local6.getBytesTotal();
if ((_local5 > 0) || (typeof(_local5) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
options.ad_failed();
_local3 = true;
}
}
if (_local4 > chk.ad_msec) {
_local3 = true;
}
if (_local3) {
if (_local2.server_control) {
delete _local2.onEnterFrame;
return(undefined);
}
_local2.fadeout_start = getTimer();
_local2.onEnterFrame = _local2.fadeFunction;
}
};
}, showPreloaderAd:function (options) {
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(options);
}, showTimedAd:function (options) {
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(options);
}, _allowDomains:function (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);
}, load:function (options) {
var _local9 = options;
var _local13 = {clip:_root, server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
_local9 = MochiAd._parseOptions(_local9, _local13);
_local9.swfv = _local9.clip.getSWFVersion() || 6;
_local9.mav = MochiAd.getVersion();
var _local8 = _local9.clip;
if (!MochiAd._isNetworkAvailable()) {
return(null);
}
if (_local8._mochiad_loaded) {
return(null);
}
var _local12 = _local9.depth;
delete _local9.depth;
var _local5 = _local8.createEmptyMovieClip("_mochiad", _local12);
var _local11 = MochiAd._getRes(_local9);
_local9.res = (_local11[0] + "x") + _local11[1];
_local9.server = _local9.server + _local9.id;
delete _local9.id;
_local8._mochiad_loaded = true;
var _local3 = _local5.createEmptyMovieClip("_mochiad_ctr", 1);
for (var _local6 in _local9) {
_local3[_local6] = _local9[_local6];
}
var _local10 = _local3.server;
delete _local3.server;
var _local14 = MochiAd._allowDomains(_local10);
_local5.onEnterFrame = function () {
var _local2 = this;
if (_local2._mochiad_ctr._url != _local2._url) {
_local2.onEnterFrame = function () {
var _local2 = this;
if (!_local2._mochiad_ctr) {
delete _local2.onEnterFrame;
MochiAd.unload(_local2._parent);
}
};
}
};
var _local4 = new LocalConnection();
var _local7 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local4.mc = _local5;
_local4.name = _local7;
_local4.hostname = _local14;
_local4.allowDomain = function (d) {
return(true);
};
_local4.allowInsecureDomain = _local4.allowDomain;
_local4.connect(_local7);
_local5.lc = _local4;
_local3.lc = _local7;
_local3.st = getTimer();
_local3.loadMovie(_local10 + ".swf", "POST");
return(_local5);
}, unload:function (clip) {
var _local2 = clip;
if (typeof(_local2) == "undefined") {
_local2 = _root;
}
if (_local2.clip && (_local2.clip._mochiad)) {
_local2 = _local2.clip;
}
if (!_local2._mochiad) {
return(false);
}
if (_local2._mochiad._containerLCName != undefined) {
_local2._mochiad.lc.send(_local2._mochiad._containerLCName, "notify", {id:"unload"});
}
_local2._mochiad.removeMovieClip();
delete _local2._mochiad_loaded;
delete _local2._mochiad;
return(true);
}, _isNetworkAvailable:function () {
if (System.security) {
var _local1 = System.security;
if (_local1.sandboxType == "localWithFile") {
return(false);
}
}
return(true);
}, _getRes:function (options) {
var _local3 = options.clip.getBounds();
var _local1 = 0;
var _local2 = 0;
if (typeof(options.res) != "undefined") {
var _local4 = options.res.split("x");
_local1 = parseFloat(_local4[0]);
_local2 = parseFloat(_local4[1]);
} else {
_local1 = _local3.xMax - _local3.xMin;
_local2 = _local3.yMax - _local3.yMin;
}
if ((_local1 == 0) || (_local2 == 0)) {
_local1 = Stage.width;
_local2 = Stage.height;
}
return([_local1, _local2]);
}, _parseOptions:function (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);
}, rpc:function (clip, callbackID, arg) {
var _local2 = clip;
var _local1 = arg;
switch (_local1.id) {
case "setValue" :
MochiAd.setValue(_local2, _local1.objectName, _local1.value);
return(undefined);
case "getValue" :
var _local3 = MochiAd.getValue(_local2, _local1.objectName);
_local2._mochiad.lc.send(_local2._mochiad._containerLCName, "rpcResult", callbackID, _local3);
return(undefined);
case "runMethod" :
var _local4 = MochiAd.runMethod(_local2, _local1.method, _local1.args);
_local2._mochiad.lc.send(_local2._mochiad._containerLCName, "rpcResult", callbackID, _local4);
return(undefined);
}
trace("[mochiads rpc] unknown rpc id: " + _local1.id);
}, setValue:function (base, objectName, value) {
var _local2 = base;
var _local3 = objectName.split(".");
var _local1;
_local1 = 0;
while (_local1 < (nameArray.length - 1)) {
if ((_local2[nameArray[_local1]] == undefined) || (_local2[nameArray[_local1]] == null)) {
return(undefined);
}
_local2 = _local2[nameArray[_local1]];
_local1++;
}
_local2[nameArray[_local1]] = value;
}, getValue:function (base, objectName) {
var _local2 = base;
var _local3 = objectName.split(".");
var _local1;
_local1 = 0;
while (_local1 < (nameArray.length - 1)) {
if ((_local2[nameArray[_local1]] == undefined) || (_local2[nameArray[_local1]] == null)) {
return(undefined);
}
_local2 = _local2[nameArray[_local1]];
_local1++;
}
return(_local2[nameArray[_local1]]);
}, runMethod:function (base, methodName, _param3) {
var _local2 = base;
var _local3 = methodName.split(".");
var _local1;
_local1 = 0;
while (_local1 < (nameArray.length - 1)) {
if ((_local2[nameArray[_local1]] == undefined) || (_local2[nameArray[_local1]] == null)) {
return(undefined);
}
_local2 = _local2[nameArray[_local1]];
_local1++;
}
if (typeof(_local2[nameArray[_local1]]) == "function") {
return(_local2[nameArray[_local1]].apply(_local2, argsArray));
}
return(undefined);
}, _:null};
MochiAd.showPreGameAd({id:"8e1cdeaef94b70b6", res:"640x480"});
Frame 2
_global.preloader();
Frame 21
function checkStage() {
var _local2 = _global;
rowBonus = 0;
row = 19;
while (row >= 0) {
if (((((((((_local2.stage_array[row][0] && (_local2.stage_array[row][1])) && (_local2.stage_array[row][2])) && (_local2.stage_array[row][3])) && (_local2.stage_array[row][4])) && (_local2.stage_array[row][5])) && (_local2.stage_array[row][6])) && (_local2.stage_array[row][7])) && (_local2.stage_array[row][8])) && (_local2.stage_array[row][9])) {
_local2.score = _local2.score + 10;
_local2.clearedLines++;
rowBonus++;
inCol = 0;
while (inCol < 10) {
mainWindow_mc[(("tile" + row.toString()) + "|") + inCol.toString()].removeMovieClip();
inCol++;
}
inRow = row;
while (inRow >= 0) {
inCol = 0;
while (inCol < 10) {
_local2.stage_array[inRow][inCol] = _local2.stage_array[inRow - 1][inCol];
if (_local2.stage_array[inRow - 1][inCol]) {
mainWindow_mc.attachMovie("tile" + mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()].saveColor, (("tile" + inRow.toString()) + "|") + inCol.toString(), _local2.depth++);
mainWindow_mc[(("tile" + inRow.toString()) + "|") + inCol.toString()].saveColor = mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()].saveColor;
mainWindow_mc[(("tile" + inRow.toString()) + "|") + inCol.toString()]._x = mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()]._x;
mainWindow_mc[(("tile" + inRow.toString()) + "|") + inCol.toString()]._y = mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()]._y + 20;
mainWindow_mc[(("tile" + (inRow - 1).toString()) + "|") + inCol.toString()].removeMovieClip();
}
inCol++;
}
inRow--;
}
col = 0;
while (col < 10) {
_local2.stage_array[0][col] = 0;
col++;
}
row++;
}
row--;
}
if (rowBonus > 1) {
_local2.score = _local2.score + (rowBonus * 5);
}
if (rowBonus == 1) {
line1_sound.start();
return(undefined);
}
if (rowBonus == 2) {
line2_sound.start();
return(undefined);
}
if (rowBonus == 3) {
line3_sound.start();
return(undefined);
}
if (rowBonus == 4) {
line4_sound.start();
}
}
function changePiece() {
var _local2 = _global;
if (_local2.currentPiece != null) {
pieces[_local2.currentPiece].setNext();
change_sound.start();
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece].removeMovieClip();
}
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local2.currentPiece].getArray()[row][col]) {
mainWindow_mc.attachMovie("tile" + _local2.lastColor, (("piece" + row.toString()) + "|") + col.toString(), _local2.depth++);
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()].saveColor = pieceColor;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._x = (col + _local2.currentPiece_col) * 20;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._y = (row + _local2.currentPiece_row) * 20;
}
col++;
}
row++;
}
}
updateHelpBar();
}
function drawPiece(moveDiag) {
var _local2 = _global;
if (_local2.currentPiece == null) {
if (_local2.nextPiece == null) {
_local2.currentPiece = Math.floor(Math.random() * 7);
_local2.nextPiece = Math.floor(Math.random() * 7);
pieceColor = Number(Math.floor(Math.random() * 5) + 1);
_local2.lastColor = pieceColor;
do {
_local2.nextPieceColor = Number(Math.floor(Math.random() * 5) + 1);
} while (_local2.nextPieceColor == pieceColor);
updatePreview();
} else {
_local2.currentPiece = _local2.nextPiece;
pieceColor = (_local2.lastColor = _local2.nextPieceColor);
_local2.nextPiece = Math.floor(Math.random() * 7);
do {
_local2.nextPieceColor = Number(Math.floor(Math.random() * 5) + 1);
} while (_local2.nextPieceColor == pieceColor);
updatePreview();
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local2.currentPiece].getArray()[row][col] && (_local2.stage_array[_local2.currentPiece_row + row][_local2.currentPiece_col + col])) {
_local2.runGame = false;
_local2.gameOver = true;
showGameOverWindow();
}
col++;
}
row++;
}
if (_local2.runGame) {
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local2.currentPiece].getArray()[row][col]) {
mainWindow_mc.attachMovie("tile" + pieceColor, (("piece" + row.toString()) + "|") + col.toString(), _local2.depth++);
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()].saveColor = pieceColor;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._x = (col + _local2.currentPiece_col) * 20;
mainWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._y = (row + _local2.currentPiece_row) * 20;
}
col++;
}
row++;
}
updateHelpBar();
}
return(undefined);
}
if ((_local2.speedCnt >= _local2.speed) || (moveDiag)) {
if (moveDownCheck()) {
if (!moveDiag) {
_local2.currentPiece_row++;
_local2.speedCnt = 0;
}
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece]._x = (Number(piece.toString().substr(7, 1)) * 20) + (_local2.currentPiece_col * 20);
mainWindow_mc[piece]._y = (Number(piece.toString().substr(5, 1)) * 20) + (_local2.currentPiece_row * 20);
}
}
} else {
_local2.score = _local2.score + 2;
drop_sound.start();
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local2.currentPiece].getArray()[row][col]) {
_local2.stage_array[_local2.currentPiece_row + row][col + _local2.currentPiece_col] = pieces[_local2.currentPiece].getArray()[row][col];
}
col++;
}
row++;
}
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece]._x = (Number(piece.toString().substr(7, 1)) * 20) + (_local2.currentPiece_col * 20);
mainWindow_mc[piece]._y = (Number(piece.toString().substr(5, 1)) * 20) + (_local2.currentPiece_row * 20);
}
}
_local2.currentPiece = null;
_local2.currentPiece_row = 0;
_local2.currentPiece_col = 4;
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
tempRow = mainWindow_mc[piece]._y / 20;
tempCol = mainWindow_mc[piece]._x / 20;
mainWindow_mc.attachMovie("tile" + mainWindow_mc[piece].saveColor, (("tile" + tempRow) + "|") + tempCol, _local2.depth++);
mainWindow_mc[(("tile" + tempRow) + "|") + tempCol]._x = mainWindow_mc[piece]._x;
mainWindow_mc[(("tile" + tempRow) + "|") + tempCol]._y = mainWindow_mc[piece]._y;
mainWindow_mc[(("tile" + tempRow) + "|") + tempCol].saveColor = mainWindow_mc[piece].saveColor;
mainWindow_mc[piece].removeMovieClip();
}
}
updateHelpBar();
}
return(undefined);
}
_local2.speedCnt++;
}
function updateHelpBar() {
var _local2 = _global;
farCol = 0;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local2.currentPiece].getArray()[row][col] && (farCol < col)) {
farCol = col;
}
col++;
}
row++;
}
helpBarWindow_mc.helpBar_mc._x = _local2.currentPiece_col * 20;
helpBarWindow_mc.helpBar_mc._width = (farCol + 1) * 20;
}
function updatePreview() {
var _local2 = _global;
for (piece_mc in previewWindow_mc) {
previewWindow_mc[piece_mc].removeMovieClip();
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (pieces[_local2.nextPiece].getArray()[row][col]) {
previewWindow_mc.attachMovie("tile" + _local2.nextPieceColor, (("piece" + row.toString()) + "|") + col.toString(), _local2.depth++);
previewWindow_mc[(("piece" + row.toString()) + "|") + col.toString()].saveColor = pieceColor;
previewWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._x = col * 20;
previewWindow_mc[(("piece" + row.toString()) + "|") + col.toString()]._y = row * 20;
}
col++;
}
row++;
}
}
function dropPiece() {
var _local2 = _global;
while (moveDownCheck()) {
_local2.currentPiece_row++;
for (piece in mainWindow_mc) {
if (piece.toString().substr(0, 5) == "piece") {
mainWindow_mc[piece]._x = (Number(piece.toString().substr(7, 1)) * 20) + (_local2.currentPiece_col * 20);
mainWindow_mc[piece]._y = (Number(piece.toString().substr(5, 1)) * 20) + (_local2.currentPiece_row * 20);
}
}
}
_local2.speedCnt = 0;
drawPiece();
}
function moveDownCheck() {
var _local2 = _global;
var _local3 = true;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if ((pieces[_local2.currentPiece].getArray()[row][col] && (_local2.stage_array[(_local2.currentPiece_row + row) + 1][col + _local2.currentPiece_col])) || (pieces[_local2.currentPiece].getArray()[row][col] && (((_local2.currentPiece_row + row) + 1) >= 20))) {
_local3 = false;
}
col++;
}
row++;
}
return(_local3);
}
function moveLeftCheck() {
var _local2 = _global;
var _local3 = true;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if ((pieces[_local2.currentPiece].getArray()[row][col] && (_local2.stage_array[_local2.currentPiece_row + row][(col + _local2.currentPiece_col) - 1])) || (_local2.currentPiece_col <= 0)) {
_local3 = false;
}
col++;
}
row++;
}
return(_local3);
}
function moveRightCheck() {
var _local2 = _global;
var _local3 = true;
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if ((pieces[_local2.currentPiece].getArray()[row][col] && (_local2.stage_array[_local2.currentPiece_row + row][(col + _local2.currentPiece_col) + 1])) || (pieces[_local2.currentPiece].getArray()[row][col] && (((col + _local2.currentPiece_col) + 1) > 9))) {
_local3 = false;
}
col++;
}
row++;
}
return(_local3);
}
function pauseGame() {
var _local2 = _global;
if ((_local2.currentPiece != null) && (!_local2.gameOver)) {
_local2.runGame = !_local2.runGame;
pause_sound.start();
if (_local2.runGame) {
stage_mc.pauseSign_mc.removeMovieClip();
return(undefined);
}
stage_mc.attachMovie("pauseSign", "pauseSign_mc", depth++);
stage_mc.pauseSign_mc._x = 275;
stage_mc.pauseSign_mc._y = 200;
}
}
function playMusic() {
var _local2 = _global;
stage_mc.title_mc.removeMovieClip();
stage_mc.attachMovie("title" + _local2.currentMusic, "title_mc", depth++);
stage_mc.title_mc._x = 12;
stage_mc.title_mc._y = 420;
if (_local2.currentMusic == 1) {
music1_sound.start();
music1_sound.onSoundComplete = function () {
music1_sound.start();
};
return(undefined);
}
if (_local2.currentMusic == 2) {
music2_sound.start();
music2_sound.onSoundComplete = function () {
music2_sound.start();
};
return(undefined);
}
if (_local2.currentMusic == 3) {
music3_sound.start();
music3_sound.onSoundComplete = function () {
music3_sound.start();
};
}
}
function showGameOverWindow() {
if (!_global.windowUp) {
stage_mc.attachMovie("gameOverWindow", "gameOverWindow_mc", depth++);
stage_mc.gameOverWindow_mc._x = 175;
stage_mc.gameOverWindow_mc._y = 100;
_global.windowUp = true;
}
}
function stopMusic() {
var _local2 = _global;
if (_local2.currentMusic == 1) {
music1_sound.stop("music1.wav");
return(undefined);
}
if (_local2.currentMusic == 2) {
music2_sound.stop("music2.wav");
return(undefined);
}
if (_local2.currentMusic == 3) {
music3_sound.stop("music3.wav");
}
}
_global.highScoresScript = "";
change_sound = new Sound();
change_sound.attachSound("change.wav");
drop_sound = new Sound();
drop_sound.attachSound("drop.wav");
pause_sound = new Sound();
pause_sound.attachSound("pause.wav");
start_sound = new Sound();
start_sound.attachSound("start.wav");
levelUp_sound = new Sound();
levelUp_sound.attachSound("levelUp.wav");
line1_sound = new Sound();
line1_sound.attachSound("line1.wav");
line2_sound = new Sound();
line2_sound.attachSound("line2.wav");
line3_sound = new Sound();
line3_sound.attachSound("line3.wav");
line4_sound = new Sound();
line4_sound.attachSound("line4.wav");
_global.depth = 0;
_global.runGame = false;
_global.gameOver = false;
_global.score = 0;
_global.level = 0;
_global.levelChange = 25;
_global.clearedLines = 0;
_global.speed = 18;
_global.speedCnt = 0;
_global.currentPiece = null;
_global.nextPiece = null;
_global.nextPieceColor = 0;
_global.currentPiece_row = 0;
_global.currentPiece_col = 4;
_global.lastColor = 0;
_global.windowUp = false;
_global.stage_array = new Array();
_global.stage_array = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
Piece = function (newPiece) {
this.piece_array = newPiece;
};
Piece.prototype.setNext = function () {
var _local2 = this;
temp_array = new Array();
temp_array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
temp_array[col][3 - row] = _local2.piece_array[row][col];
col++;
}
row++;
}
_local2.piece_array = temp_array;
while (!(((_local2.piece_array[0][0] || (_local2.piece_array[1][0])) || (_local2.piece_array[2][0])) || (_local2.piece_array[3][0]))) {
row = 0;
while (row < 4) {
col = 1;
while (col < 4) {
_local2.piece_array[row][col - 1] = _local2.piece_array[row][col];
col++;
}
row++;
}
_local2.piece_array[0][3] = 0;
_local2.piece_array[1][3] = 0;
_local2.piece_array[2][3] = 0;
_local2.piece_array[3][3] = 0;
}
};
Piece.prototype.testNext = function () {
var _local3 = _global;
var _local4 = this;
returnBool = true;
temp_array = new Array();
temp_array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
temp_array[col][3 - row] = _local4.piece_array[row][col];
col++;
}
row++;
}
while (!(((temp_array[0][0] || (temp_array[1][0])) || (temp_array[2][0])) || (temp_array[3][0]))) {
row = 0;
while (row < 4) {
col = 1;
while (col < 4) {
temp_array[row][col - 1] = temp_array[row][col];
col++;
}
row++;
}
temp_array[0][3] = 0;
temp_array[1][3] = 0;
temp_array[2][3] = 0;
temp_array[3][3] = 0;
}
row = 0;
while (row < 4) {
col = 0;
while (col < 4) {
if (((temp_array[row][col] && (_local3.stage_array[row + _local3.currentPiece_row][col + _local3.currentPiece_col])) || (temp_array[row][col] && ((col + _local3.currentPiece_col) > 9))) || (temp_array[row][col] && ((row + _local3.currentPiece_row) > 19))) {
returnBool = false;
}
col++;
}
row++;
}
return(returnBool);
};
Piece.prototype.getArray = function () {
return(this.piece_array);
};
pieces = new Array();
pieces.push(new Piece([[1, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[1, 1, 1, 0], [0, 0, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[0, 0, 1, 0], [1, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[0, 1, 0, 0], [1, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]));
pieces.push(new Piece([[0, 1, 0, 0], [1, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0]]));
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = _global;
if (_local2.runGame && (_local2.currentPiece != null)) {
if (Key.isDown(37)) {
if (moveLeftCheck()) {
_local2.currentPiece_col--;
}
drawPiece(true);
updateHelpBar();
return(undefined);
}
if (Key.isDown(39)) {
if (moveRightCheck()) {
_local2.currentPiece_col++;
}
drawPiece(true);
updateHelpBar();
return(undefined);
}
if (Key.isDown(38)) {
if (pieces[_local2.currentPiece].testNext()) {
changePiece();
}
return(undefined);
}
if (Key.isDown(40)) {
dropPiece();
}
}
};
Key.addListener(keyListener);
playMusic();
stage_mc.createEmptyMovieClip("scoreWindow_mc", depth++);
stage_mc.scoreWindow_mc._x = 105;
stage_mc.scoreWindow_mc._y = 182;
stage_mc.scoreWindow_mc.score = -1;
stage_mc.createEmptyMovieClip("levelWindow_mc", depth++);
stage_mc.levelWindow_mc._x = 20;
stage_mc.levelWindow_mc._y = 182;
stage_mc.scoreWindow_mc.onEnterFrame = function () {
var _local2 = _global;
if (stage_mc.scoreWindow_mc.score < _local2.score) {
stage_mc.scoreWindow_mc.score++;
for (num in stage_mc.scoreWindow_mc) {
stage_mc.scoreWindow_mc[num].removeMovieClip();
}
newNumString = "000000".concat(stage_mc.scoreWindow_mc.score.toString()).substring(stage_mc.scoreWindow_mc.score.toString().length + 1, stage_mc.scoreWindow_mc.score.toString().length + 6);
pos = 0;
while (pos < newNumString.length) {
stage_mc.scoreWindow_mc.attachMovie("num" + newNumString.substr(pos, 1), "num" + pos, depth++);
stage_mc.scoreWindow_mc["num" + pos]._x = pos * 25;
stage_mc.scoreWindow_mc["num" + pos]._y = 0;
pos++;
}
if ((_local2.clearedLines >= _local2.levelChange) || (_local2.level == 0)) {
for (num in stage_mc.levelWindow_mc) {
stage_mc.levelWindow_mc[num].removeMovieClip();
}
_local2.level++;
if (_local2.level != 1) {
levelUp_sound.start();
}
_local2.clearedLines = 0;
if (_local2.speed >= 0) {
_local2.speed--;
}
newNumString = "00".concat(_local2.level.toString()).substring(_local2.level.toString().length, _local2.level.toString().length + 2);
pos = 0;
while (pos < newNumString.length) {
stage_mc.levelWindow_mc.attachMovie("num" + newNumString.substr(pos, 1), "num" + pos, depth++);
stage_mc.levelWindow_mc["num" + pos]._x = pos * 25;
stage_mc.levelWindow_mc["num" + pos]._y = 0;
pos++;
}
}
}
};
stage_mc.pauseGame_btn.onPress = function () {
if (!_global.windowUp) {
pauseGame();
}
};
stage_mc.pause_mc.onPress = function () {
stopMusic();
};
stage_mc.play_mc.onPress = function () {
playMusic();
};
stage_mc.ff_mc.onPress = function () {
stopMusic();
if ((++_global.currentMusic) > 3) {
_global.currentMusic = 1;
}
playMusic();
};
stage_mc.rewind_mc.onPress = function () {
stopMusic();
if ((--_global.currentMusic) < 1) {
_global.currentMusic = 3;
}
playMusic();
};
stage_mc.highScores_btn.onPress = function () {
var _local2 = _global;
if (_local2.runGame) {
pauseGame();
}
if (!_local2.windowUp) {
stage_mc.attachMovie("highScoresWindow", "highScoresWindow_mc", depth++);
stage_mc.highScoresWindow_mc._x = 175;
stage_mc.highScoresWindow_mc._y = 100;
_local2.windowUp = true;
}
};
stage_mc.newGame_btn.onPress = function () {
var _local2 = _global;
if (!_local2.windowUp) {
start_sound.start();
_local2.runGame = true;
_local2.gameOver = false;
_local2.score = 0;
_local2.level = 0;
_local2.clearedLines = 0;
_local2.speed = 18;
_local2.speedCnt = 0;
stage_mc.scoreWindow_mc.score = -1;
for (piece in mainWindow_mc) {
mainWindow_mc[piece].removeMovieClip();
}
_local2.currentPiece = null;
_local2.currentPiece_row = 0;
_local2.currentPiece_col = 4;
stage_mc.pauseSign_mc.removeMovieClip();
_local2.stage_array = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
}
};
stage_mc.onEnterFrame = function () {
if (_global.runGame) {
checkStage();
drawPiece();
}
};
Symbol 22 MovieClip [gameOverWindow] Frame 1
_global.windowUp = false;
gameOver_mc.removeMovieClip();