Frame 1
function Sprites() {
function initZArray(ary) {
var _local1 = 0;
while (_local1 < zRange) {
ary[_local1] = zRange - _local1;
_local1++;
}
}
createEmptyMovieClip("sprite_root", 0);
var spriteCounter = 0;
var zRange = 500;
var rootZArray = new Array(zRange);
initZArray(rootZArray);
var groupList = new Object();
this.getNumFree = function () {
return(zArray.length);
};
this.create = function (props) {
var _local5 = "sprite" + spriteCounter;
var _local3;
var _local4;
if ((typeof(props.group) == "string") && (groupList[props.group])) {
_local4 = (props.z ? (props.z) : (groupList[props.group].ZArray.pop() + zRange));
groupList[props.group].createEmptyMovieClip(_local5, _local4);
_local3 = groupList[props.group][_local5];
_local3.memberOf = props.group;
} else {
_local4 = (props.z ? (props.z) : (rootZArray.pop() + zRange));
sprite_root.createEmptyMovieClip(_local5, _local4);
_local3 = sprite_root[_local5];
_local3.memberOf = null;
}
if (typeof(props.member) == "string") {
_local3.attachMovie(props.member, "member_mc", _local4);
}
_local3._x = ((typeof(props.x) == "number") ? (props.x) : (Stage.width / 2));
_local3._y = ((typeof(props.y) == "number") ? (props.y) : (Stage.height / 2));
if (typeof(props.width) == "number") {
_local3._width = props.width;
}
if (typeof(props.height) == "number") {
_local3._height = props.height;
}
if (typeof(props.xscale) == "number") {
_local3._xscale = props.xscale;
}
if (typeof(props.yscale) == "number") {
_local3._yscale = props.yscale;
}
_local3._visible = ((typeof(props.visible) == "boolean") ? (props.visible) : true);
_local3._alpha = ((typeof(props.alpha) == "number") ? (props.alpha) : 100);
_local3.zIndex = _local4;
_local3.spriteIndex = spriteCounter;
_local3.toBack = function () {
var _local2 = this.zIndex % zRange;
this.swapDepths(_local2);
this.member_mc.swapDepths(_local2);
this.zIndex = _local2;
};
_local3.toFront = function () {
var _local2 = (this.zIndex % zRange) + (zRange * 2);
this.swapDepths(_local2);
this.member_mc.swapDepths(_local2);
this.zIndex = _local2;
};
spriteCounter++;
return(_local3);
};
this.swapZIndex = function (a, b) {
if (typeof(b) == "movieclip") {
a.swapDepths(b);
var _local3 = a.zIndex;
a.zIndex = b.zIndex;
b.zIndex = _local3;
} else {
a.swapDepths(parseInt(b));
a.zIndex = b;
}
};
this.createGroup = function (props) {
if (typeof(props.group) == "string") {
var _local2 = props.group;
props.group = null;
if (groupList[_local2]) {
wr("Alert! generating an already existing group: ", _local2);
} else {
groupList[_local2] = this.create(props);
groupList[_local2].groupName = _local2;
groupList[_local2].zArray = new Array(zRange);
initZArray(groupList[_local2].zArray);
}
}
return(groupList[_local2]);
};
this.removeGroup = function (nameOrSprite) {
if (typeof(nameOrSprite) == "string") {
gName = nameOrSprite;
} else {
gName = nameOrSprite.groupName;
}
if (groupList[gName]) {
sprites.remove(groupList[gName]);
groupList[gName] = null;
}
};
this.setMember = function (sprite, member) {
sprite.attachMovie(member, "member_mc", sprite.getDepth());
};
this.getMembers = function (sprite) {
var _local1 = new Array();
if (groupList[sprite.groupName]) {
_local1 = sprite.memberClips;
}
return(_local1);
};
this.createText = function (props) {
var _local5 = this.create({x:props.x, y:props.y});
_local5.createTextField("member_mc", _local5.zIndex, 0, 0, 1, 1);
var _local3 = _local5.member_mc;
_local3.autosize = ((typeof(props.align) == "string") ? (props.align) : "left");
_local3.multiline = false;
_local3.wordWrap = false;
_local3.border = false;
_local3.selectable = false;
_local3.type = "dynamic";
_local3.embedFonts = true;
var _local4 = new TextFormat();
_local4.color = ((typeof(props.color) == "string") ? (props.color) : "0xffffff");
_local4.size = props.size || 9;
_local4.font = ((typeof(props.font) == "string") ? (props.font) : "Arial");
_local4.align = ((typeof(props.align) == "string") ? (props.align) : "left");
_local4.bold = ((typeof(props.bold) == "boolean") ? (props.bold) : false);
_local3.setNewTextFormat(_local4);
_local3.text = ((typeof(props.text) == "string") ? (props.text) : "");
return(_local5);
};
this.remove = function (sprite) {
if (!sprite.zIndex) {
return(undefined);
}
var _local2 = sprite.zIndex % zRange;
if ((sprite.memberOf != null) && (groupList[sprite.memberOf])) {
groupList[sprite.memberOf].ZArray.push(_local2);
} else {
rootZArray.push(_local2);
}
sprite.removeMovieClip();
return(_local2);
};
}
function Events() {
var listeners = new Array();
var stopCount = 0;
this.runIt = function (object) {
if (typeof(object.run) == "function") {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
return(undefined);
}
_local1++;
}
listeners.push(object);
} else {
wr("tried to run bad object!");
wrObj(object);
}
};
this.stopIt = function (object) {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
stopCount++;
listeners[_local1].eventOrphan = true;
return(undefined);
}
_local1++;
}
};
onEnterFrame = function () {
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (!_local2[_local1].eventOrphan) {
_local2[_local1].run();
}
_local1++;
}
if (stopCount > 0) {
_local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1].eventOrphan) {
listeners[_local1].eventOrphan = false;
listeners.splice(_local1, 1);
_local1--;
stopCount--;
}
_local1++;
}
}
};
this.putEventList = function () {
wr("Running Object list:");
var _local1 = 0;
while (_local1 < listeners.length) {
wr(listeners[_local1]);
_local1++;
}
};
this.checkEventList = function () {
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (typeof(_local2[_local1]) != "object") {
wr("invalid object in event: ", _local1);
}
_local1++;
}
};
}
function SoundFx() {
this.playSounds = true;
var _local4 = ["kick_1.wav", "kick_2.wav", "kick_3.wav", "kick_4.wav", "kick_5.wav", "kick_6.wav", "click", "morph", "switch", "bomb", "intro_sound", "nomoremoves_sound", "gameover_sound", "loop_sound"];
createEmptyMovieClip("sound_fx", -1);
var _local6 = 0;
var backgroundLoopStarted = false;
var sounds = new Object();
var _local5 = new Sound();
_local5.setVolume(65);
var _local2 = 0;
while (_local2 < _local4.length) {
var _local3 = new Sound(sound_fx.createEmptyMovieClip("sound_" + (_local2 + 1), (-_local2) - 2));
_local3.attachSound(_local4[_local2]);
if (_local4[_local2].indexOf("loop") > -1) {
_local3.onSoundComplete = function () {
this.start();
};
} else if (_local4[_local2].indexOf("intro") > -1) {
_local3.onSoundComplete = function () {
this.playing = false;
soundFx.playBackgroundLoop();
};
} else {
_local3.onSoundComplete = function () {
this.playing = false;
};
}
if (_local4[_local2].indexOf("kick_") == 0) {
_local3.setVolume(65);
}
if (_local4[_local2].indexOf("loop") == 0) {
_local3.setVolume(65);
}
if (_local4[_local2].indexOf("intro") == 0) {
_local3.setVolume(65);
}
sounds[_local4[_local2]] = _local3;
sounds[_local4[_local2]].playing = false;
_local2++;
}
this.playBackgroundLoop = function () {
this.play("loop_sound");
backgroundLoopStarted = true;
};
this.play = function (sound, nostop) {
if (sounds[sound].playing) {
if (nostop) {
return(undefined);
}
this.stop(sound);
}
if (this.playSounds) {
sounds[sound].playing = true;
sounds[sound].start();
}
};
this.stop = function (sound) {
sounds[sound].stop();
sounds[sound].playing = false;
};
this.toggleOnOff = function () {
if (this.playSounds) {
this.stop("intro_sound");
this.stop("loop_sound");
this.playSounds = false;
} else {
this.playSounds = true;
this.play("loop_sound");
}
};
}
function wr() {
var _local3 = "> ";
var _local2 = 0;
while (_local2 < arguments.length) {
_local3 = _local3 + arguments[_local2];
_local2++;
if (arguments.length != _local2) {
_local3 = _local3 + " ";
}
}
trace(_local3);
}
function wrObj(obj, rec) {
function wrObjDump(obj, rec, currprop) {
currprop = ((typeof(currprop) == "string") ? (currprop + ".") : "");
for (prop in obj) {
trace(((currprop + prop) + ": ") + obj[prop]);
if (rec) {
if (typeof(obj[prop]) == "object") {
wrObjDump(obj[prop], rec, currprop + prop);
}
}
}
}
trace("--- Obj dump: ---------");
wrObjDump(obj, rec);
trace("-----------------------");
}
function fill(width, p) {
var _local2 = "";
var _local3 = ((typeof(p) != "string") ? " " : (p));
var _local1 = 0;
while (_local1 < width) {
_local2 = _local2 + _local3;
_local1++;
}
return(_local2);
}
function setBrightness(clip, bright) {
if (typeof(clip) == "movieclip") {
var col = new Color(clip);
var trans = col.getTransform();
with (trans) {
ra = (ga = (ba = 100 - Math.abs(bright)));
rb = (gb = (bb = ((bright > 0) ? (bright * 2.56) : 0)));
}
col.setTransform(trans);
}
}
function Random() {
var seed = 0;
var seed2 = 0;
this.range = function (start, stop) {
var _local2 = stop - start;
var _local1 = Math.random() * (_local2 + 1);
_local1 = Math.floor(start + _local1);
return(Math.min(_local1, stop));
};
this.setSeed = function (s) {
wr("setSeed:", s);
seed = s & 65535;
seed2 = seed;
};
this.rangeFromSeed = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.rangeFromSeed2 = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed2() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.floatFromSeed = function () {
seed = ((seed * 732573) + 3545443) & 65535;
temp = seed / 65536;
return(temp);
};
this.floatFromSeed2 = function () {
seed2 = ((seed2 * 732573) + 3545443) & 65535;
temp = seed2 / 65536;
return(temp);
};
}
function Slide(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.orig_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.orig_y));
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.callback = props.callback;
this.delay = props.delay || 0;
this.v = 0;
this.nFrames = props.nFrames || 10;
this.run = function () {
if (this.delay > 0) {
this.delay--;
return(undefined);
}
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), (Math.PI/2));
if (this.move_x) {
this.curr_x = this.orig_x + ((Math.sin(this.v + 4.71238898038469) + 1) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + ((Math.sin(this.v + 4.71238898038469) + 1) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
}
if (this.v >= (Math.PI/2)) {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
};
events.runIt(this);
}
function Fade(props) {
this.mysprite = props.sprite;
this.mode = ((typeof(props.mode) == "string") ? (props.mode) : "in");
this.nFrames = props.frames || 10;
this.counter = this.nFrames;
this.alphastep = 100 / this.nFrames;
if (this.mode == "in") {
this.alphastep = -this.alphastep;
this.curralpha = 0;
} else {
this.curralpha = 100;
}
this.callback = props.callback;
this.run = function () {
this.counter--;
this.curralpha = this.curralpha - this.alphastep;
this.mysprite._alpha = this.curralpha;
if (this.counter == 0) {
if (this.mode == "pulse") {
this.counter = this.nFrames;
this.alphastep = -this.alphastep;
} else {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
}
};
events.runIt(this);
}
function Delay(what, frames) {
this.what = what;
this.counter = 0;
this.nFrames = frames;
this.run = function () {
this.counter++;
if (this.counter > this.nFrames) {
events.stopIt(this);
this.what();
}
};
events.runIt(this);
}
function Animate(props) {
this.running = false;
this.mysprite = props.sprite;
this.callback = props.callback;
this.delay = props.delay || 0;
this.frameRate = props.frameRate || 0;
this.frameCounter = this.frameRate;
this.animation = props.animation;
this.animpos = 0;
this.loop = ((typeof(props.loop) == "boolean") ? (props.loop) : false);
this.start = function () {
if (this.running) {
return(undefined);
}
this.running = true;
events.runIt(this);
};
this.run = function () {
if (this.delay > 0) {
this.delay--;
return(undefined);
}
if (this.animpos > this.animation.length) {
if (this.loop) {
this.animpos = 0;
} else {
this.running = false;
events.stopIt(this);
if (this.callback) {
this.callback();
}
return(undefined);
}
}
if (this.frameCounter > 0) {
this.frameCounter--;
return(undefined);
}
sprites.setMember(this.mysprite, this.animation[this.animpos]);
this.animpos++;
this.frameCounter = this.frameRate;
};
this.kill = function () {
events.stopIt(this);
};
}
function Gui() {
function isString(str) {
return(typeof(str) == "string");
}
var sound_button = snd_btn;
var end_game_button = end_game_btn;
var finalTexts = {};
var finalSprite;
this.infoSprite = null;
var topIndicators = [];
var T_time_left = time_text;
var _local15 = points_text;
var TH_time_left = time_tag_text;
var TH_points = points_tag_text;
var p_automat = new scoreAutomat(_local15);
events.runIt(p_automat);
var _local26 = sprites.createGroup({group:"topGroup", member:"top_blocks", x:144.5, y:-5.7, width:461, height:33.4});
_local26.toFront();
var _local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
topIndicators.push(sprites.create({group:"topGroup", member:"top_indicator", x:BLOCK_WIDTH * _local2, y:18, width:BLOCK_WIDTH, height:16.6, visible:false}));
topIndicators[_local2].toFront();
_local2++;
}
this.setupGui = function (props) {
TH_time_left.text = (isString(props.time) ? (props.time) : "TIME");
TH_points.text = (isString(props.points) ? (props.points) : "POINTS");
end_game_button.label.text = (isString(props.end_game) ? (props.end_game) : "END GAME");
var _local11 = (isString(props.instruction_head) ? (props.instruction_head) : "");
var _local12 = (isString(props.instruction1) ? (props.instruction1) : "");
var _local5 = (isString(props.instruction2) ? (props.instruction2) : "");
var _local14 = (isString(props.instruction3) ? (props.instruction3) : "");
var _local13 = (isString(props.start_game) ? (props.start_game) : "START GAME");
var _local7 = (isString(props.start_in) ? (props.start_in) : "START IN");
this.infoSprite = sprites.create({member:"instructions", x:146, y:35, visible:false});
var _local8 = this.infoSprite.member_mc.header_txt;
_local8.text = _local11;
var _local4 = this.infoSprite.member_mc.p1_txt;
_local4.autoSize = "center";
_local4.text = (((_local12 + "\n\n") + _local5) + "\n\n") + _local14;
var _local3 = this.infoSprite.member_mc.start_btn;
_local3.label_txt.autoSize = "center";
_local3.label_txt.text = _local13;
_local3.useHandCursor = false;
_local3.onRelease = function () {
game.gui.removeInfo();
};
this.infoSprite.countdownSprite = this.infoSprite.member_mc.countdown;
this.infoSprite.countdownSprite.sec = 10;
this.infoSprite.countdownSprite.start_in = _local7;
this.infoSprite.countdownSprite.frameCounter = 25;
this.infoSprite.countdownSprite.setText = function () {
this.txt.text = (this.start_in + " ") + this.sec;
};
this.infoSprite.countdownSprite.run = function () {
if (this.frameCounter == 0) {
if (this.sec == 0) {
events.stopIt(this);
game.gui.removeInfo();
} else {
this.frameCounter = 25;
this.sec--;
this.setText();
}
} else {
this.frameCounter--;
}
};
this.infoSprite.countdownSprite.setText();
var _local6 = (isString(props.game_over) ? (props.game_over) : "BONUS");
var _local10 = (isString(props.bonus) ? (props.bonus) : "BONUS");
var _local9 = (isString(props.final_score) ? (props.final_score) : "SCORE");
this.setUpFinal(_local6, _local10, _local9);
};
this.showInfo = function () {
this.infoSprite._visible = true;
events.runIt(this.infoSprite.countdownSprite);
};
this.removeInfo = function () {
if (this.tmpIsCalled) {
delete this.tmpIsCalled;
return(undefined);
}
this.tmpIsCalled = true;
var _local2 = function () {
sprites.remove(game.gui.infoSprite);
delete game.gui.infoSprite;
var _local1 = function () {
game.onStartGame();
};
new Delay(_local1, 1);
};
new Slide({sprite:this.infoSprite, y:this.infoSprite._y + 50});
new Fade({sprite:this.infoSprite, mode:"out", callback:_local2});
};
this.setUpFinal = function (gameover, bonus, finalscore) {
finalTexts.gameover = gameover;
finalTexts.bonus = bonus;
finalTexts.finalscore = finalscore;
};
this.showIndicator = function (index) {
topIndicators[index]._visible = true;
};
this.hideIndicators = function () {
var _local1 = 0;
while (_local1 < topIndicators.length) {
topIndicators[_local1]._visible = false;
_local1++;
}
};
end_game_button._visible = false;
end_game_button.btn.useHandCursor = false;
end_game_button.btn.onRelease = function () {
fscommand ("playData", "1977,0");
this.onRelease = null;
game.setGameOver("user");
};
sound_button.btn.useHandCursor = false;
sound_button.btn.onRelease = function () {
game.toggleSound();
};
this.toggleSound = function () {
if (sound_button._currentFrame == 1) {
sound_button.nextFrame();
} else {
sound_button.prevFrame();
}
};
this.gameIsOver = function (props) {
sound_button.onRelease = null;
finalSprite = sprites.create({member:"final", x:146, y:35, visible:false});
finalSprite.member_mc.gameover_txt.text = finalTexts.gameover;
var _local4 = ((("1. " + finalTexts.bonus) + " (") + new String(props.bonus)) + ")";
var _local3 = ((("2. " + finalTexts.finalscore) + " (") + new String(props.score)) + ")";
var _local2 = finalSprite.member_mc.final_txt1;
var _local1 = finalSprite.member_mc.final_txt2;
_local2.autoSize = "center";
_local1.autoSize = "center";
_local2.text = _local4;
_local1.text = _local3;
finalSprite._visible = true;
};
this.setTime = function (time) {
T_time_left.text = time;
};
this.addPoints = function (points) {
p_automat.addScore(points);
};
this.showEndGameButton = function () {
end_game_button._visible = true;
};
}
function scoreAutomat(txt_field) {
function updateScore() {
var _local1 = dest_p - curr_p;
var _local2 = _local1 * speed;
if (Math.abs(_local1) <= 2) {
curr_p = dest_p;
} else {
curr_p = curr_p + _local2;
}
txt_field.text = Math.round(curr_p);
if (dest_p == curr_p) {
calcReady();
}
}
function calcReady() {
running = false;
}
var running = false;
var speed = 0.2;
var curr_p = 0;
var dest_p = 0;
var txt_field = txt_field;
this.addScore = function (howMuch) {
running = true;
if ((dest_p + howMuch) < 0) {
dest_p = 0;
} else {
dest_p = dest_p + howMuch;
}
};
this.run = function () {
if (running) {
updateScore();
}
};
}
function blockDropper() {
var dropList = new Array();
var speedList = [2, 7, 10, 18, 18, 19];
var speedList = [10, 16, 19];
var min_y = BLOCK_DROP_START_Y;
this.start = function () {
events.runIt(this);
};
this.dropBlock = function (props) {
var _local1 = new Object();
_local1.sprite = props.sprite;
_local1.orig_y = _local1.sprite._y;
_local1.curr_y = _local1.orig_y;
_local1.sprite.droptarget_y = ((typeof(props.y) == "number") ? (props.y) : (_local1.orig_y));
_local1.move_y = _local1.orig_y != _local1.sprite.droptarget_y;
_local1.callback = props.callback;
_local1.speedListPos = 0;
_local1.speed = 0;
_local1.sprite._y = Math.max(_local1.orig_y, min_y);
_local1.sprite._visible = true;
dropList.push(_local1);
};
this.run = function () {
var _local2;
var _local3;
var _local4 = false;
var _local1 = 0;
while (_local1 < dropList.length) {
_local2 = dropList[_local1].sprite;
_local3 = typeof(_local2.gridX) != "number";
if ((dropList[_local1].curr_y == _local2.droptarget_y) || (_local3)) {
_local4 = true;
if (!_local3) {
_local2.busy = false;
}
if (dropList[_local1].callback) {
dropList[_local1].callback();
}
dropList.splice(_local1, 1);
_local1--;
} else {
dropList[_local1].speed = speedList[dropList[_local1].speedListPos];
dropList[_local1].curr_y = Math.min(dropList[_local1].curr_y + dropList[_local1].speed, _local2.droptarget_y);
_local2._y = Math.max(min_y, dropList[_local1].curr_y);
dropList[_local1].speedListPos++;
if (dropList[_local1].speedListPos == speedList.length) {
dropList[_local1].speedListPos = speedList.length - 2;
}
}
_local1++;
}
};
this.clear = function () {
};
}
function GameOverAnimation(ary) {
this.postScoreDelay = 75;
var self = this;
var y2 = (GAME_ARRAY_HEIGHT - 1);
var _local3 = 0;
while (_local3 < GAME_ARRAY_WIDTH) {
var _local2 = GAME_ARRAY_HEIGHT - 1;
while (_local2 > -1) {
var block = ary[_local3][_local2];
if ((block.STATE == BLOCK_STATES.INITIAL) && (block.TYPE != BLOCK_TYPES.BOMB)) {
block.OUTER_VALUE = block.INNER_VALUE;
}
var _local5 = function () {
var _local2 = this._parent;
if (block.STATE == BLOCK_STATES.INITIAL) {
_local2.outerSprite.removeMovieClip();
}
if ((_local2.gridX == (GAME_ARRAY_WIDTH - 1)) && (_local2.gridY == 0)) {
events.runIt(self);
}
};
block.transformSprite = block.attachMovie(block.OUTER_VALUE + BLOCK_SUFFIX.CLEAR_TO, "mc_transformSprite", 2);
block.transformSprite.callback = _local5;
if ((block.STATE != BLOCK_STATES.INITIAL) || (block.TYPE == BLOCK_TYPES.BOMB)) {
block.transformSprite._visible = false;
}
if (block.innerSprite) {
block.innerSprite.removeMovieClip();
}
_local2--;
}
_local3++;
}
this.run = function () {
if (y2 > -1) {
var _local3 = 0;
while (_local3 < GAME_ARRAY_WIDTH) {
var _local2 = ary[_local3][y2];
var _local5 = function () {
var _local2 = this._parent;
if ((_local2.gridX == (GAME_ARRAY_WIDTH - 1)) && (_local2.gridY == 0)) {
new Delay(function () {
game.generateMagicBall();
}, self.postScoreDelay);
}
};
_local2.exitSprite = _local2.attachMovie(_local2.OUTER_VALUE + BLOCK_SUFFIX.EXIT, "mc_exitSprite", 3);
_local2.exitSprite.callback = _local5;
_local2.transformSprite.removeMovieClip();
_local3++;
}
if (y2 == (GAME_ARRAY_HEIGHT - 1)) {
var _local6 = {score:game.score.getScore(), bonus:game.score.getBonus()};
game.gui.gameIsOver(_local6);
}
y2--;
} else {
events.stopIt(this);
}
};
}
function Score() {
var currentLevel = 1;
var comboScores = [0, 0, 50, 100, 150, 250, 500];
var comboScorePerAdditionalBlock = 250;
var matchScores = [0, 50, 100, 150, 200, 250, 300, 350, 400];
var bonusMultiplier = 3;
var nonScoringMoveScore = -11;
var noMoreMovesScore = -500;
var bombScore = 200;
var matchIndex = 0;
var currentScore = 0;
var blockCounter = 0;
var eventCodes = {};
eventCodes.swap = 78;
eventCodes.switch = 78;
eventCodes[COMBO_TYPES.COLOR] = 573;
eventCodes[COMBO_TYPES.BOMB] = 198;
eventCodes.bonus = 4978;
eventCodes.inactive = 237;
eventCodes["non-scoring move"] = 4824;
this.getLevel = function () {
return(currentLevel);
};
this.getScore = function () {
return(currentScore + this.getBonus());
};
this.getBonus = function () {
return(blockCounter * bonusMultiplier);
};
this.evaluateEvent = function (event) {
var _local3 = 0;
event.code = -1;
wr("event:", event.action, ", value:", event.value, ", matchIndex:", matchIndex, ", moveString:", event.moveString);
if (event.action == COMBO_TYPES.COLOR) {
blockCounter = blockCounter + event.value;
var _local6 = Math.min(comboScores.length, event.value);
_local3 = comboScores[_local6 - 1];
_local3 = _local3 + (Math.Max(0, event.value - comboScores.length) * comboScorePerAdditionalBlock);
_local3 = _local3 + matchScores[matchIndex];
wr("score: " + _local3);
matchIndex++;
matchIndex = Math.min(matchIndex, matchScores.length - 1);
var _local5 = ("kick_" + Math.min(matchIndex, 6)) + ".wav";
if (!game.gameOver) {
soundFx.play(_local5);
}
} else if (event.action == COMBO_TYPES.BOMB) {
blockCounter = blockCounter + event.value;
_local3 = bombScore;
wr("SCORE : " + _local3);
matchIndex++;
matchIndex = Math.min(matchIndex, matchScores.length - 1);
if (!game.gameOver) {
soundFx.play("bomb");
}
} else if (event.action == "reset multiplier") {
matchIndex = 0;
} else if (event.action == "non-scoring move") {
_local3 = nonScoringMoveScore;
} else if (event.action == "no more moves") {
if (!game.gameOver) {
soundFx.play("nomoremoves_sound");
}
_local3 = noMoreMovesScore;
} else if (event.action == "bonus") {
event.value = blockCounter;
} else if (event.action == "inactive") {
_local3 = -1;
}
var _local4 = currentScore;
currentScore = currentScore + _local3;
currentScore = Math.max(0, currentScore);
if (!game.gameOver) {
game.gui.addPoints(_local3);
}
event.code = eventCodes[event.action] || 0;
if (event.action == "bonus") {
event.score = this.getBonus();
this.sendEvent(event);
} else if ((event.action == "swap") || (event.action == "switch")) {
event.score = 0;
this.sendEvent(event);
} else if (_local4 != currentScore) {
event.score = currentScore - _local4;
this.sendEvent(event);
}
return(_local3);
};
this.sendEvent = function (props) {
if (game.gameOver) {
return(undefined);
}
var _local2 = String(props.code);
if (props.code == 573) {
_local2 = _local2 + ("," + String(props.value));
_local2 = _local2 + (" " + String(props.removedValue));
}
if (props.code == 198) {
_local2 = _local2 + ("," + String(props.value));
_local2 = _local2 + (" " + String(props.removedValue));
}
if (props.code == 78) {
_local2 = _local2 + ("," + String(props.moveString));
}
if (props.code == 4978) {
_local2 = _local2 + ("," + String(props.value));
}
_local2 = _local2 + ("=" + String(props.score));
fscommand ("playData", _local2);
};
}
function Logger() {
var theLog = new Array();
this.logEvent = function (data) {
theLog.push(data);
};
this.getLog = function () {
return(theLog);
};
}
function ScorePop(x, y, score, fontsize) {
var _local3 = {text:score + "", x:x, y:y, bold:true, size:fontsize || 14, align:"center"};
var _local2 = sprites.createText(_local3);
_local2.member_mc.background = true;
_local2.member_mc.backgroundColor = "0x404040";
_local2.toFront();
this.mysprite = _local2;
this.orig_y = this.mysprite._y;
this.curr_y = this.orig_y;
this.endPos = this.orig_y - 37;
if (this.endPos < 15) {
this.endPos = 15;
}
this.target_y = this.endPos;
this.move_y = this.orig_y != this.target_y;
this.v = 0;
this.nFrames = 10;
this.state = 1;
this.fadecounter = 100;
this.run = function () {
if (this.state == 1) {
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), (Math.PI/2));
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
if (this.v >= (Math.PI/2)) {
this.state++;
}
} else if (this.state == 2) {
this.fadecounter = this.fadecounter - 9;
this.mysprite._alpha = this.fadecounter;
if (this.fadecounter < 10) {
events.stopIt(this);
sprites.remove(this.mysprite);
}
}
};
events.runIt(this);
}
function SlideSlow(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.orig_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.orig_y));
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.callback = props.callback;
if (props.slideBack == true) {
this.slideBack = true;
} else {
this.slideBack = false;
}
this.v = 0;
this.nFrames = props.nFrames || 10;
this.run = function () {
var _local2 = (Math.PI/2);
if (this.slideBack) {
_local2 = Math.PI;
}
this.v = Math.min(this.v + (Math.PI / (this.nFrames * 2)), _local2);
if (this.move_x) {
this.curr_x = this.orig_x + (Math.sin(this.v) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
}
if (this.v >= _local2) {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
};
events.runIt(this);
}
function Initslide(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.orig_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.orig_y));
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.callback = props.callback;
this.delay = props.delay || 0;
this.v = 0;
this.nFrames = props.nFrames || 10;
this.run = function () {
if (this.delay > 0) {
this.delay--;
return(undefined);
}
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), (Math.PI/2));
if (this.move_x) {
this.curr_x = this.orig_x + (Math.sin(this.v) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
if (this.curr_y > 10) {
this.mysprite._visible = true;
}
this.mysprite._y = this.curr_y;
}
if (this.v >= (Math.PI/2)) {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
};
events.runIt(this);
}
function Game() {
function start() {
var _local1 = new XML();
_local1.ignoreWhite = true;
_local1.parseXML(gameData);
allBlocks.feedSymbols = ((typeof(_local1.firstChild.attributes.symbols) == "string") ? (String(_local1.firstChild.attributes.symbols).split(" ")) : null);
allBlocks.levelSymbols = ((typeof(_local1.firstChild.attributes.start) == "string") ? (String(_local1.firstChild.attributes.start).split(" ")) : null);
gameDuration = ((typeof(_local1.firstChild.attributes.timelimit) == "string") ? (parseInt(_local1.firstChild.attributes.timelimit) * 1000) : 180000);
noMovesText = ((typeof(_local1.nomoves.firstChild.nodeValue) == "string") ? (_local1.nomoves.firstChild.nodeValue) : "No more moves!");
var _local2 = new Object();
_local2.time = _local1.time_left.firstChild.nodeValue;
_local2.points = _local1.score.firstChild.nodeValue;
_local2.end_game = _local1.end_game.firstChild.nodeValue;
_local2.instruction_head = _local1.instruction_header.firstChild.nodeValue;
_local2.instruction1 = _local1.instruction_text_1.firstChild.nodeValue;
_local2.instruction2 = _local1.instruction_text_2.firstChild.nodeValue;
_local2.instruction3 = _local1.instruction_text_3.firstChild.nodeValue;
_local2.start_game = _local1.start_game.firstChild.nodeValue;
_local2.bonus = _local1.symbol_bonus.firstChild.nodeValue;
_local2.final_score = _local1.result.firstChild.nodeValue;
_local2.game_over = _local1.game_over.firstChild.nodeValue;
_local2.start_in = _local1.start_in.firstChild.nodeValue;
game.gui.setupGui(_local2);
createFeedArray();
createLevelArray();
fps_status = new Object();
fps_status.lastTime = getTimer();
fps_status.frameCnt = 0;
soundFx.play("intro_sound");
game.gui.showInfo();
}
function createFeedArray() {
allBlocks.feedArray = new Array();
if (allBlocks.feedSymbols != null) {
var _local3 = 0;
while (_local3 < allBlocks.feedSymbols.length) {
var _local4 = allBlocks.feedSymbols[_local3];
var _local7 = _local4.charAt(0);
var _local2 = _local4.charAt(1);
var _local5 = ((_local2 == SPECIALS.RAINBOW) ? (BLOCK_TYPES.RAINBOW) : (((_local2 == SPECIALS.BOMB) ? (BLOCK_TYPES.BOMB) : (BLOCK_TYPES.NORMAL))));
var _local6 = createBlockObject(_local7, _local2, _local5);
allBlocks.feedArray.push(_local6);
_local3++;
}
} else {
var _local10 = 900;
var _local11 = 5;
var _local12 = 5;
var _local9 = Math.round(_local10 * (_local11 / 100));
var _local8 = Math.round(_local10 * (_local12 / 100));
var _local3 = 0;
while (_local3 < _local10) {
var _local1;
if (_local9 > 0) {
_local1 = getRandBlockObject(null, BLOCK_TYPES.RAINBOW);
_local9--;
} else if (_local8 > 0) {
_local1 = getRandBlockObject(null, BLOCK_TYPES.BOMB);
_local8--;
} else {
_local1 = getRandBlockObject(null, BLOCK_TYPES.NORMAL);
}
allBlocks.feedArray.push(_local1);
_local3++;
}
allBlocks.feedArray = allBlocks.feedArray.sort(function (a, b) {
return(((Math.floor(Math.random() * 2) == 0) ? 1 : -1));
});
}
}
function createLevelArray() {
allBlocks.levelArray = new Array();
if (allBlocks.levelSymbols != null) {
var _local7 = 0;
while (_local7 < allBlocks.levelSymbols.length) {
var _local8 = allBlocks.levelSymbols[_local7];
var _local10 = _local8.charAt(0);
var _local11 = _local8.charAt(1);
var _local9 = BLOCK_TYPES.NORMAL;
allBlocks.levelArray.push(createBlockObject(_local10, _local11, _local9));
_local7++;
}
} else {
var _local12 = (GAME_ARRAY_WIDTH * GAME_ARRAY_HEIGHT) * 10;
var _local7 = 0;
while (_local7 < _local12) {
var _local5 = new Array();
var _local1 = new Array();
var _local4 = 0;
while (_local4 < GAME_ARRAY_WIDTH) {
_local1.push(new Array());
var _local3 = 0;
while (_local3 < GAME_ARRAY_HEIGHT) {
_local1[_local4].push(false);
_local3++;
}
_local1[_local4].blockCount = 0;
_local3 = 0;
while (_local3 < GAME_ARRAY_HEIGHT) {
var _local2 = getRandBlockObject({ary:_local1, x:_local4, y:_local3}, BLOCK_TYPES.NORMAL);
_local1[_local4][_local3] = _local2;
_local5.push(_local2);
_local3++;
}
_local4++;
}
allBlocks.levelArray = allBlocks.levelArray.concat(_local5);
_local7 = _local7 + (GAME_ARRAY_WIDTH * GAME_ARRAY_HEIGHT);
}
}
}
function getRandBlockObject(comboprops, type) {
var _local2 = type;
var _local1 = BLOCK_COLORS[random.range(0, NUMBER_OF_COLORS - 1)];
if (_local2 == BLOCK_TYPES.NORMAL) {
var _local10 = BLOCK_COLORS[random.range(0, NUMBER_OF_COLORS - 1)];
while (_local10 == _local1) {
_local10 = BLOCK_COLORS[random.range(0, NUMBER_OF_COLORS - 1)];
}
} else if (_local2 == BLOCK_TYPES.RAINBOW) {
var _local10 = SPECIALS.RAINBOW;
} else if (_local2 == BLOCK_TYPES.BOMB) {
var _local10 = SPECIALS.BOMB;
}
if (comboprops != null) {
var _local4 = comboprops.ary;
var _local6 = comboprops.x;
var _local5 = comboprops.y;
var _local9 = checkBlockDown(_local6, _local5 - 1, _local1, _local4);
var _local8 = checkBlockLeft(_local6 - 1, _local5, _local1, _local4);
var _local7 = 1 + Math.max(_local9.length, _local8.length);
if (_local7 >= MIN_COMBO_LENGTH) {
return(getRandBlockObject(comboprops, type));
}
}
return(createBlockObject(_local1, _local10, _local2));
}
function createBlockObject(pOuterValue, pInnerValue, pType) {
var _local1 = new Object();
_local1.busy = false;
_local1.tagged = false;
_local1.STATE = BLOCK_STATES.INITIAL;
_local1.TYPE = pType;
_local1.OUTER_VALUE = pOuterValue;
_local1.INNER_VALUE = pInnerValue;
return(_local1);
}
function attachOuterSprite(block, symbol, zIndex) {
if (block.outerSprite) {
block.outerSprite.removeMovieClip();
}
var _local2 = ((typeof(zIndex) == "number") ? (zIndex) : 1);
block.outerSprite = block.attachMovie(symbol, "outerSprite_mc", _local2);
}
function attachInnerSprite(block, symbol, zIndex, memberProps) {
if (block.innerSprite) {
block.innerSprite.removeMovieClip();
}
var _local2 = ((typeof(zIndex) == "number") ? (zIndex) : 0);
block.innerSprite = block.attachMovie(symbol, "innerSprite_mc", _local2, memberProps);
}
function onSwitchClick(clickedBlock) {
deSelectBlock();
if (clickedBlock.STATE == BLOCK_STATES.SOLID) {
return(false);
}
game.sliding = true;
var _local2 = {action:"switch", moveString:(((((clickedBlock.INNER_VALUE + " ") + clickedBlock.OUTER_VALUE) + " ") + clickedBlock.gridX) + " ") + clickedBlock.gridY};
game.evaluateEvent(_local2);
if (clickedBlock.TYPE == BLOCK_TYPES.BOMB) {
clickedBlock.STATE = BLOCK_STATES.BOMB;
game.evaluateSwitch(clickedBlock);
} else {
var _local3 = function () {
_root.game.evaluateSwitch(clickedBlock);
};
soundFx.play("morph");
switchBlock(clickedBlock, _local3);
}
}
function onSwapClick(b1, b2) {
deSelectBlock();
setClickTime();
var _local4 = b1.gridX;
var _local2 = b1.gridY;
var _local3 = b2.gridX;
var _local1 = b2.gridY;
var _local5 = false;
if ((_local4 == _local3) && (Math.abs(_local2 - _local1) == 1)) {
_local5 = true;
}
if ((_local2 == _local1) && (Math.abs(_local4 - _local3) == 1)) {
_local5 = true;
}
if (!_local5) {
return(undefined);
}
gameArray[_local4][_local2] = b2;
gameArray[_local3][_local1] = b1;
b1.gridX = _local3;
b1.gridY = _local1;
b2.gridX = _local4;
b2.gridY = _local2;
game.sliding = true;
var _local6 = {action:"swap", moveString:(((((((((b1.OUTER_VALUE + " ") + b1.gridX) + " ") + b1.gridY) + " ") + b2.OUTER_VALUE) + " ") + b2.gridX) + " ") + b2.gridY};
game.evaluateEvent(_local6);
game.evaluateEvent({action:"reset multiplier"});
var _local8 = checkBlock(_local4, _local2, true);
var _local11 = checkBlock(_local4, _local2, false);
var _local7 = checkBlock(_local3, _local1, true);
var _local9 = checkBlock(_local3, _local1, false);
var _local10 = Math.max(Math.max(_local8, _local11), Math.max(_local7, _local9));
sprites.swapZIndex(b1, b2);
if (_local10 < MIN_COMBO_LENGTH) {
gameArray[_local4][_local2] = b1;
gameArray[_local3][_local1] = b2;
b1.gridX = _local4;
b1.gridY = _local2;
b2.gridX = _local3;
b2.gridY = _local1;
var _local12 = function () {
game.sliding = false;
game.onNonScoringMove();
sprites.swapZIndex(b1, b2);
};
props = {sprite:b1, slideBack:true, x:GAME_ARRAY_POS_X + (_local3 * BLOCK_WIDTH), y:GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - _local1) - 1) * BLOCK_HEIGHT)};
new SlideSlow(props);
var props = {callback:_local12, slideBack:true, sprite:b2, x:GAME_ARRAY_POS_X + (_local4 * BLOCK_WIDTH), y:GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - _local2) - 1) * BLOCK_HEIGHT)};
new SlideSlow(props);
} else {
var _local12 = function () {
game.onSuccessfulClick();
};
props = {sprite:b1, x:GAME_ARRAY_POS_X + (_local3 * BLOCK_WIDTH), y:GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - _local1) - 1) * BLOCK_HEIGHT)};
new SlideSlow(props);
var props = {callback:_local12, sprite:b2, x:GAME_ARRAY_POS_X + (_local4 * BLOCK_WIDTH), y:GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - _local2) - 1) * BLOCK_HEIGHT)};
new SlideSlow(props);
}
soundFx.play("switch");
}
function switchBlock(block, callback) {
var _local2 = block.OUTER_VALUE;
block.OUTER_VALUE = block.INNER_VALUE;
block.INNER_VALUE = _local2;
block.switchToSprite = block.attachMovie(block.OUTER_VALUE + BLOCK_SUFFIX.SWITCH_TO, "switchTo_mc", 2);
block.switchToSprite.callback = callback;
block.switchToSprite.gotoAndPlay(_local2);
}
function selectBlock(block) {
setBrightness(block, CLICK_BRIGHTNESS);
selectedBlock = block;
}
function deSelectBlock() {
setBrightness(selectedBlock, 0);
selectedBlock = false;
}
function registerCombo(x, y, len, dir, comboType) {
setClickTime();
var _local7 = {type:comboType, blocks:new Array()};
var _local10 = {action:comboType};
var _local12 = 0;
var _local11 = 0;
var _local6 = 0;
if (comboType == COMBO_TYPES.COLOR) {
_local10.value = len;
_local12 = ((dir == "v") ? (GAME_ARRAY_POS_X + ((x + 0.5) * BLOCK_WIDTH)) : (GAME_ARRAY_POS_X + ((x - (len / 2)) * BLOCK_WIDTH)));
_local11 = ((dir == "v") ? ((GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - y) + (len / 2)) * BLOCK_HEIGHT)) - 8) : ((GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - y) - 1) * BLOCK_HEIGHT)) + 10));
while (len > 0) {
var _local1 = ((dir == "v") ? (gameArray[x][y - len]) : (gameArray[x - len][y]));
if (!_local1.tagged) {
if ((_local1.TYPE == BLOCK_TYPES.BOMB) && (_local1.STATE != BLOCK_STATES.BOMB)) {
_local1.STATE = BLOCK_STATES.BOMB;
registerCombo(_local1.gridX, _local1.gridY, null, null, COMBO_TYPES.BOMB);
} else {
_local1.tagged = true;
pendingChangingBlocks++;
_local7.blocks.push(_local1);
if ((_local1.STATE == BLOCK_STATES.SOLID) || (_local1.STATE == BLOCK_STATES.BOMB)) {
_local6++;
}
}
}
len--;
}
_local10.removedValue = _local6;
} else if (comboType == COMBO_TYPES.BOMB) {
len = 0;
var _local5 = new Array();
_local5.push(gameArray[x][y]);
_local5.push(gameArray[x - 1][y + 1]);
_local5.push(gameArray[x - 1][y]);
_local5.push(gameArray[x - 1][y - 1]);
_local5.push(gameArray[x][y + 1]);
_local5.push(gameArray[x][y - 1]);
_local5.push(gameArray[x + 1][y + 1]);
_local5.push(gameArray[x + 1][y]);
_local5.push(gameArray[x + 1][y - 1]);
var _local2 = 0;
while (_local2 < _local5.length) {
var _local1 = _local5[_local2];
if (!_local1) {
} else {
len++;
if (!_local1.tagged) {
if ((_local1.TYPE == BLOCK_TYPES.BOMB) && (_local1.STATE != BLOCK_STATES.BOMB)) {
_local1.STATE = BLOCK_STATES.BOMB;
registerCombo(_local1.gridX, _local1.gridY, null, null, COMBO_TYPES.BOMB);
} else {
_local1.tagged = true;
pendingChangingBlocks++;
_local7.blocks.push(_local1);
if ((_local1.STATE == BLOCK_STATES.SOLID) || (_local1.STATE == BLOCK_STATES.BOMB)) {
_local6++;
}
}
}
}
_local2++;
}
_local10.value = len;
_local10.removedValue = _local6;
_local12 = GAME_ARRAY_POS_X + ((x + 0.5) * BLOCK_WIDTH);
_local11 = (GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - y) - 1) * BLOCK_HEIGHT)) + 10;
}
removeList.push(_local7);
var _local14 = game.evaluateEvent(_local10);
new ScorePop(_local12, _local11, _local14);
}
function checkBlockRight(x, y, strCheckValue, ary) {
var _local1 = x;
var _local2 = ary || (gameArray);
while (((((_local2[_local1][y] && (strCheckValue == SPECIALS.RAINBOW)) || (_local2[_local1][y].OUTER_VALUE == strCheckValue)) || (_local2[_local1][y].OUTER_VALUE == SPECIALS.RAINBOW)) && (!_local2[_local1][y].busy)) && ((!_local2[_local1][y].tagged) || (_local2[_local1][y].OUTER_VALUE == SPECIALS.RAINBOW))) {
if (strCheckValue == SPECIALS.RAINBOW) {
strCheckValue = _local2[_local1][y].OUTER_VALUE;
}
_local1++;
}
return({length:_local1 - x, checkValue:strCheckValue});
}
function checkBlockLeft(x, y, strCheckValue, ary) {
var _local1 = x;
var _local2 = ary || (gameArray);
while (((((_local2[_local1][y] && (strCheckValue == SPECIALS.RAINBOW)) || (_local2[_local1][y].OUTER_VALUE == strCheckValue)) || (_local2[_local1][y].OUTER_VALUE == SPECIALS.RAINBOW)) && (!_local2[_local1][y].busy)) && ((!_local2[_local1][y].tagged) || (_local2[_local1][y].OUTER_VALUE == SPECIALS.RAINBOW))) {
if (strCheckValue == SPECIALS.RAINBOW) {
strCheckValue = _local2[_local1][y].OUTER_VALUE;
}
_local1--;
}
return({length:x - _local1, checkValue:strCheckValue});
}
function checkBlockUp(x, y, strCheckValue, ary) {
var _local1 = y;
var _local2 = ary || (gameArray);
while (((((_local2[x][_local1] && (strCheckValue == SPECIALS.RAINBOW)) || (_local2[x][_local1].OUTER_VALUE == strCheckValue)) || (_local2[x][_local1].OUTER_VALUE == SPECIALS.RAINBOW)) && (!_local2[x][_local1].busy)) && ((!_local2[x][_local1].tagged) || (_local2[x][_local1].OUTER_VALUE == SPECIALS.RAINBOW))) {
if (strCheckValue == SPECIALS.RAINBOW) {
strCheckValue = _local2[x][_local1].OUTER_VALUE;
}
_local1++;
}
return({length:_local1 - y, checkValue:strCheckValue});
}
function checkBlockDown(x, y, strCheckValue, ary) {
var _local1 = y;
var _local2 = ary || (gameArray);
while (((((_local2[x][_local1] && (strCheckValue == SPECIALS.RAINBOW)) || (_local2[x][_local1].OUTER_VALUE == strCheckValue)) || (_local2[x][_local1].OUTER_VALUE == SPECIALS.RAINBOW)) && (!_local2[x][_local1].busy)) && ((!_local2[x][_local1].tagged) || (_local2[x][_local1].OUTER_VALUE == SPECIALS.RAINBOW))) {
if (strCheckValue == SPECIALS.RAINBOW) {
strCheckValue = _local2[x][_local1].OUTER_VALUE;
}
_local1--;
}
return({length:y - _local1, checkValue:strCheckValue});
}
function checkBlock(x, y, bVertical) {
var _local3 = gameArray[x][y];
var _local4 = 1;
var _local2;
var _local1;
if (bVertical) {
_local2 = checkBlockDown(x, y - 1, _local3.OUTER_VALUE);
_local1 = checkBlockUp(x, y + 1, _local3.OUTER_VALUE);
} else {
_local2 = checkBlockLeft(x - 1, y, _local3.OUTER_VALUE);
_local1 = checkBlockRight(x + 1, y, _local3.OUTER_VALUE);
}
if (_local3.OUTER_VALUE == SPECIALS.RAINBOW) {
if (((_local2.checkValue == _local1.checkValue) || (_local2.checkValue == SPECIALS.RAINBOW)) || (_local1.checkValue == SPECIALS.RAINBOW)) {
_local4 = _local4 + (_local2.length + _local1.length);
} else {
_local4 = _local4 + Math.Max(_local2.length, _local1.length);
}
} else {
_local4 = _local4 + (_local2.length + _local1.length);
}
return(_local4);
}
function killTaggedBlocks() {
var _local4 = 0;
while (_local4 < removeList.length) {
var _local3 = removeList[_local4];
var _local2 = 0;
while (_local2 < _local3.blocks.length) {
var _local1 = _local3.blocks[_local2];
_local1.busy = true;
_local1.tagged = false;
if ((_local1.STATE == BLOCK_STATES.SOLID) || (_local1.STATE == BLOCK_STATES.BOMB)) {
game.removeBlock(_local1);
} else if (_local1.STATE == BLOCK_STATES.INITIAL) {
game.createSolidBlock(_local1);
}
_local2++;
}
_local4++;
}
removeList = new Array();
}
function moveDownBlocks() {
var _local3 = 0;
while (_local3 < gameArray.length) {
var _local4 = 0;
var _local7 = 0;
while (_local7 < gameArray[_local3].length) {
if (gameArray[_local3][_local7]) {
if (_local4 < _local7) {
var _local2 = gameArray[_local3][_local7];
var _local5 = _local2.gridY - _local4;
if (_local2.busy) {
_local2.droptarget_y = _local2.droptarget_y + (_local5 * BLOCK_HEIGHT);
} else {
var _local6 = function () {
this.sprite.pushed = true;
game.droppingBlockCnt--;
if (game.droppingBlockCnt == 0) {
game.gui.hideIndicators();
game.checkCombos();
}
};
var _local8 = {sprite:_local2, y:_local2._y + (_local5 * BLOCK_HEIGHT), callback:_local6};
game.blockDropper.dropBlock(_local8);
game.droppingBlockCnt++;
_local2.busy = true;
}
_local2.gridY = _local4;
gameArray[_local3][_local4] = _local2;
gameArray[_local3][_local7] = false;
_local4++;
} else {
_local4++;
}
}
_local7++;
}
_local3++;
}
}
function testSwitch(x, y) {
var _local1 = gameArray[x][y];
if (_local1.TYPE == BLOCK_TYPES.BOMB) {
return(true);
}
if (_local1.STATE == BLOCK_STATES.SOLID) {
return(false);
}
var _local2 = _local1.OUTER_VALUE;
_local1.OUTER_VALUE = _local1.INNER_VALUE;
_local1.INNER_VALUE = _local2;
var _local5 = checkBlock(x, y, true);
var _local4 = checkBlock(x, y, false);
var _local3 = Math.max(_local5, _local4);
_local1.INNER_VALUE = _local1.OUTER_VALUE;
_local1.OUTER_VALUE = _local2;
return(_local3 >= MIN_COMBO_LENGTH);
}
function testSwap(x1, y1, x2, y2) {
var _local5 = gameArray[x1][y1];
gameArray[x1][y1] = gameArray[x2][y2];
gameArray[x2][y2] = _local5;
var _local7 = checkBlock(x1, y1, true);
var _local10 = checkBlock(x1, y1, false);
var _local6 = checkBlock(x2, y2, true);
var _local8 = checkBlock(x2, y2, false);
var _local9 = Math.max(Math.max(_local7, _local10), Math.max(_local6, _local8));
gameArray[x2][y2] = gameArray[x1][y1];
gameArray[x1][y1] = _local5;
return(_local9 >= MIN_COMBO_LENGTH);
}
function checkPossibleMoves() {
if (game.droppingBlockCnt > 0) {
return(undefined);
}
if (game.sliding == true) {
return(undefined);
}
if (game.isRemoving == true) {
return(undefined);
}
var _local1 = Math.floor(game.blockcheckCount / 2);
if ((_local1 * 2) == game.blockcheckCount) {
game.blockCheckData[_local1] = new Array();
}
var _local6 = Math.floor(GAME_ARRAY_WIDTH / 2) * (game.blockcheckCount % 2);
var _local7 = _local6 + Math.floor(GAME_ARRAY_WIDTH / 2);
var _local5 = _local6;
while (_local5 < _local7) {
if ((_local5 < GAME_ARRAY_WIDTH) && (_local1 < GAME_ARRAY_HEIGHT)) {
if (testSwitch(_local5, _local1)) {
game.blockCheckData[_local1].push({x:_local5});
}
}
if (_local5 < (GAME_ARRAY_WIDTH - 1)) {
if (testSwap(_local5, _local1, _local5 + 1, _local1)) {
game.blockCheckData[_local1].push({x:_local5, vertical:false});
}
}
if (_local1 < (GAME_ARRAY_HEIGHT - 1)) {
if (testSwap(_local5, _local1, _local5, _local1 + 1)) {
game.blockCheckData[_local1].push({x:_local5, vertical:true});
}
}
_local5++;
}
game.blockcheckCount = (game.blockcheckCount + 1) % (GAME_ARRAY_HEIGHT * 2);
if (game.blockcheckCountOnClick == game.blockcheckCount) {
game.blockcheckCountOnline = true;
var _local3;
var _local2 = 0;
while (_local2 < GAME_ARRAY_HEIGHT) {
_local3 = _local3 + game.blockCheckData[_local2].length;
if (_local3 > 0) {
break;
}
_local2++;
}
if (_local3 == 0) {
game.evaluateEvent({action:"no more moves"});
game.killLevel();
var _local8 = new ScorePop(380, 250, noMovesText, 12);
_local8.target_y = 112;
_local8.nFrames = 15;
return(undefined);
}
}
}
function setClickTime(secs) {
var _local1 = new Date().getTime();
if (secs) {
_local1 = _local1 + secs;
}
for (var _local2 in clickTimeDefault) {
clickTime[_local2] = _local1;
}
}
function checkClickTime(prop, no_reset) {
if (clickTime[prop] == 0) {
return(false);
}
var _local2 = new Date().getTime();
if ((_local2 - clickTime[prop]) >= clickTimeDefault[prop]) {
if (no_reset) {
clickTime[prop] = 0;
} else {
clickTime[prop] = _local2;
}
return(true);
}
return(false);
}
function needsNewBlocks() {
var _local1 = 0;
while (_local1 < GAME_ARRAY_WIDTH) {
if (gameArray[_local1].blockCount < GAME_ARRAY_HEIGHT) {
return(true);
}
_local1++;
}
return(false);
}
var self = this;
var gameNotStarted = true;
var gameOverreason;
var tryGameOver = false;
var noMovesText;
var startedGameOverSound = false;
var clientServerTimeDiff = {counter:0, sum:0, counterStart:0};
this.frameCnt = 0;
this.gameOver = false;
this.sliding = false;
this.changingLevel = true;
this.isRemoving = false;
this.blockcheckCount = 0;
this.blockcheckCountOnClick = 0;
this.blockcheckCountOnline = false;
this.blockCheckData = new Array();
this.blockDropper = new blockDropper();
this.blockDropper.start();
var clickTimeDefault = {inactive:5000};
var clickTime = {};
var gameArray;
var removeList = new Array();
var pendingChangingBlocks = 0;
this.score = new Score();
var log = new Logger();
this.gui = new Gui();
this.droppingBlockCnt = 0;
var startTime = new Date().getTime();
var gameDuration;
var allBlocks = {feedSymbols:[], levelSymbols:[], feedArray:[], levelArray:[]};
var selectedBlock;
var blocksParent = sprites.createGroup({group:"blockSprites", x:0, y:0});
var fps_status;
this.initialize = function () {
var _local2 = new Object();
_local2.run = function () {
if (gameData != undefined) {
events.stopIt(this);
game.callStart();
}
};
events.runIt(_local2);
};
this.callStart = function () {
start();
};
this.onStartGame = function () {
this.gui.showEndGameButton();
this.setUpLevel();
events.runIt(self);
wr("start game.run");
fscommand ("gameStart");
};
this.run = function () {
this.frameCnt++;
var _local2 = getTimer();
fps_status.frameCnt++;
if ((_local2 - fps_status.lastTime) > 1000) {
info_text.text = "fps: " + fps_status.frameCnt;
fps_status.lastTime = _local2;
fps_status.frameCnt = 0;
}
if (tryGameOver) {
this.setGameOver2();
}
if (this.gameOver) {
return(undefined);
}
if (game.changingLevel == true) {
clientServerTimeDiff.counter = _local2 - clientServerTimeDiff.counterStart;
return(undefined);
}
if (clientServerTimeDiff.counter > 0) {
clientServerTimeDiff.sum = clientServerTimeDiff.sum + clientServerTimeDiff.counter;
clientServerTimeDiff.counter = 0;
}
clientServerTimeDiff.counterStart = _local2;
if (checkClickTime("inactive")) {
game.evaluateEvent({action:"inactive", value:null});
}
if (gameNotStarted) {
startTime = _local2;
}
if ((playTime != undefined) && (playTime != 0)) {
var _local7 = (parseInt(playTime) * 1000) - clientServerTimeDiff.sum;
startTime = _local2 - _local7;
playTime = undefined;
} else {
var _local7 = _local2 - startTime;
}
var _local5 = gameDuration - _local7;
if ((_local5 <= 5000) && (!startedGameOverSound)) {
soundFx.stop("loop_sound");
startedGameOverSound = true;
soundFx.play("gameover_sound");
}
if (_local5 <= 0) {
game.setGameOver("time");
}
var _local3 = Math.round(_local5 / 1000);
_local3 = Math.max(0, _local3);
_local3 = Math.min(gameDuration, _local3);
var _local6 = String(Math.floor(_local3 / 60) + ":");
var _local4 = _local3 % 60;
_local6 = _local6 + ((_local4 < 10) ? ("0" + _local4) : (_local4));
this.gui.setTime(_local6);
checkPossibleMoves();
};
this.getFeedBlockObject = function () {
if (allBlocks.feedArray.length == 0) {
createFeedArray();
}
return(allBlocks.feedArray.shift());
};
this.pushBlock = function (x, obj, insert_y, z) {
if (typeof(insert_y) != "number") {
insert_y = GAME_ARRAY_HEIGHT - 1;
}
var _local10 = gameArray[x].length - 1;
while (_local10 > insert_y) {
gameArray[x][_local10] = gameArray[x][_local10 - 1];
gameArray[x][_local10].gridY = _local10;
gameArray[x][_local10]._y = GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - _local10) - 1) * BLOCK_HEIGHT);
_local10--;
}
_local10 = insert_y;
if (typeof(z) != "string") {
z = ("1" + _local10) + x;
}
var _local11 = {group:blocksParent.groupName, visible:false, x:GAME_ARRAY_POS_X + (x * BLOCK_WIDTH), y:GAME_ARRAY_POS_Y + (((GAME_ARRAY_HEIGHT - _local10) - 1) * BLOCK_HEIGHT), z:z};
var _local2 = sprites.create(_local11);
_local2.useHandCursor = false;
_local2.gridX = x;
_local2.gridY = _local10;
_local2.busy = false;
_local2.pushed = false;
_local2.tagged = false;
_local2.STATE = obj.STATE;
_local2.TYPE = obj.TYPE;
_local2.INNER_VALUE = obj.INNER_VALUE;
_local2.OUTER_VALUE = obj.OUTER_VALUE;
var _local9 = {_x:INSIDE_OFFSET_X, _y:INSIDE_OFFSET_Y};
var _local6 = 0;
if (obj.TYPE == BLOCK_TYPES.BOMB) {
_local9 = null;
_local6 = 1;
}
attachInnerSprite(_local2, obj.INNER_VALUE + BLOCK_SUFFIX.INSIDE, _local6, _local9);
var _local7 = obj.OUTER_VALUE + BLOCK_SUFFIX.FRAME;
var _local8 = 1;
if (obj.TYPE == BLOCK_TYPES.BOMB) {
_local7 = obj.OUTER_VALUE + BLOCK_SUFFIX.SOLID;
_local8 = 0;
}
attachOuterSprite(_local2, _local7, _local8);
if (!tryGameOver) {
_local2.onPress = function () {
game.clickBlock(this);
};
}
gameArray[x][_local10] = _local2;
gameArray[x].blockCount++;
return(true);
};
this.setUpLevel = function () {
if (allBlocks.levelArray.length < (GAME_ARRAY_WIDTH * GAME_ARRAY_WIDTH)) {
createLevelArray();
}
this.blockCheckData = new Array();
setClickTime(2000);
if (gameArray) {
gameArray = null;
}
deSelectBlock();
this.droppingBlockCnt = 0;
this.sliding = false;
this.isRemoving = false;
var _local13 = 0;
gameArray = new Array();
var _local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
gameArray.push(new Array());
var _local11 = 0;
while (_local11 < GAME_ARRAY_HEIGHT) {
gameArray[_local2].push(false);
_local11++;
}
gameArray[_local2].blockCount = 0;
_local11 = 0;
while (_local11 < GAME_ARRAY_HEIGHT) {
var _local5 = allBlocks.levelArray.shift();
this.pushBlock(_local2, _local5, _local11);
_local11++;
}
_local2++;
}
_local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
var _local12 = function () {
game.droppingBlockCnt--;
if (game.droppingBlockCnt == 0) {
game.checkCombos();
}
};
var _local10 = function () {
game.droppingBlockCnt--;
if (game.droppingBlockCnt == 0) {
game.checkCombos();
}
};
var _local11 = 0;
while (_local11 < GAME_ARRAY_HEIGHT) {
var _local3 = _local11 + _local2;
var _local4 = gameArray[_local2][_local11]._y;
gameArray[_local2][_local11]._y = BLOCK_DROP_START_Y;
if ((_local11 == 0) && ((_local2 % 2) == 0)) {
props = {callback:_local12, sprite:gameArray[_local2][_local11], y:_local4, delay:_local3, nFrames:4};
} else {
props = {callback:_local10, sprite:gameArray[_local2][_local11], y:_local4, delay:_local3, nFrames:4};
}
new Initslide(props);
game.droppingBlockCnt++;
_local11++;
}
_local2++;
}
game.changingLevel = false;
moveDownBlocks();
};
this.killLevel = function () {
game.changingLevel = true;
var _local4 = 0;
var _local10 = function () {
sprites.remove(this.mysprite);
};
var _local3 = 0;
var _local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
var _local9 = 0;
while (_local9 < GAME_ARRAY_HEIGHT) {
tmpSprite = gameArray[_local2][_local9];
if (tmpSprite) {
tmpSprite.onPress = null;
_local3 = _local9 + _local2;
new Slide({sprite:tmpSprite, y:tmpSprite._y + 400, nFrames:15, callback:_local10, delay:_local3});
_local4 = Math.max(_local4, _local3);
}
_local9++;
}
_local2++;
}
var _local11 = function () {
if (game.gameOver) {
return(undefined);
}
game.setUpLevel();
};
var _local12 = new _local5[undefined](_local11, _local4 + 16);
};
this.nextLevel = function () {
this.killLevel();
};
this.getLevel = function () {
return(this.score.getLevel());
};
this.clickBlock = function (clickedBlock) {
if (this.droppingBlockCnt > 0) {
return(undefined);
}
if (this.sliding == true) {
return(undefined);
}
if (this.isRemoving == true) {
return(undefined);
}
if (selectedBlock) {
if (selectedBlock == clickedBlock) {
onSwitchClick(clickedBlock);
} else {
onSwapClick(clickedBlock, selectedBlock);
}
} else {
soundFx.play("click");
selectBlock(clickedBlock);
}
};
this.evaluateSwitch = function (clickedBlock) {
setClickTime();
this.evaluateEvent({action:"reset multiplier"});
if (clickedBlock.STATE == BLOCK_STATES.INITIAL) {
clickedBlock.innerSprite.removeMovieClip();
var _local3 = clickedBlock.gridX;
var _local2 = clickedBlock.gridY;
var _local6 = checkBlock(_local3, _local2, true);
var _local5 = checkBlock(_local3, _local2, false);
var _local4 = Math.max(_local6, _local5);
if (_local4 < MIN_COMBO_LENGTH) {
attachOuterSprite(clickedBlock, clickedBlock.OUTER_VALUE + BLOCK_SUFFIX.FRAME);
var _local7 = function () {
attachOuterSprite(clickedBlock, clickedBlock.OUTER_VALUE + BLOCK_SUFFIX.FRAME, 1);
attachInnerSprite(clickedBlock, clickedBlock.INNER_VALUE + BLOCK_SUFFIX.INSIDE, 0, {_x:INSIDE_OFFSET_X, _y:INSIDE_OFFSET_Y});
clickedBlock.switchToSprite.removeMovieClip();
game.sliding = false;
game.onNonScoringMove();
};
switchBlock(clickedBlock, _local7);
} else {
clickedBlock.outerSprite.removeMovieClip();
this.onSuccessfulClick();
}
} else if (clickedBlock.STATE == BLOCK_STATES.BOMB) {
this.onSuccessfulClick();
}
};
this.onSuccessfulClick = function () {
setClickTime();
this.blockcheckCountOnClick = (this.blockcheckCount = this.blockcheckCount - (this.blockcheckCount % 2));
this.blockcheckCountOnline = false;
this.sliding = false;
this.checkCombos();
};
this.createSolidBlock = function (block) {
block.clearToSprite = block.attachMovie(block.INNER_VALUE + BLOCK_SUFFIX.CLEAR_TO, "mc_clearToSprite", 3);
var _local3 = function () {
var _local2 = this._parent;
attachOuterSprite(_local2, _local2.INNER_VALUE + BLOCK_SUFFIX.SOLID);
_local2.clearToSprite.removeMovieClip();
if (_local2.innerSprite) {
_local2.innerSprite.removeMovieClip();
}
if (_local2.switchToSprite) {
_local2.switchToSprite.removeMovieClip();
}
_local2.OUTER_VALUE = _local2.INNER_VALUE;
_local2.INNER_VALUE = null;
_local2.STATE = BLOCK_STATES.SOLID;
_local2.busy = false;
game.onBlockStateChanged();
};
block.clearToSprite.callback = _local3;
};
this.removeBlock = function (block) {
this.gui.showIndicator(block.gridX);
gameArray[block.gridX][block.gridY] = false;
gameArray[block.gridX].blockCount--;
if (block.STATE == BLOCK_STATES.SOLID) {
block.exitSprite = block.attachMovie(block.OUTER_VALUE + BLOCK_SUFFIX.EXIT, "mc_exitSprite", 2);
var _local4 = function () {
game.onBlockStateChanged();
sprites.remove(this._parent);
};
block.exitSprite.callback = _local4;
block.outerSprite.removeMovieClip();
} else if (block.STATE == BLOCK_STATES.BOMB) {
var _local4 = function () {
game.onBlockStateChanged();
sprites.remove(this);
};
var _local3 = sprites.create({member:SPECIALS.BOMB + BLOCK_SUFFIX.EXIT, x:block._x - 28, y:block._y - 10});
_local3.toFront();
_local3.callback = _local4;
sprites.remove(block);
}
};
this.onBlockStateChanged = function () {
pendingChangingBlocks--;
if (pendingChangingBlocks == 0) {
this.isRemoving = false;
if (needsNewBlocks()) {
this.feedNewBlocks();
} else {
this.checkCombos();
}
}
};
this.onNonScoringMove = function () {
var _local1 = game.evaluateEvent({action:"non-scoring move"});
};
this.checkCombos = function () {
gameNotStarted = false;
var _local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
var _local4 = 0;
while (_local4 < GAME_ARRAY_HEIGHT) {
if (gameArray[_local2][_local4].STATE == BLOCK_STATES.BOMB) {
registerCombo(_local2, _local4, null, null, COMBO_TYPES.BOMB);
}
_local4++;
}
_local2++;
}
var _local3 = -1;
var _local5 = 1;
_local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
var _local4 = 0;
while (_local4 < (GAME_ARRAY_HEIGHT + 1)) {
if (((gameArray[_local2][_local4].OUTER_VALUE == _local3) || (gameArray[_local2][_local4] && (_local3 == SPECIALS.RAINBOW))) || ((gameArray[_local2][_local4].OUTER_VALUE == SPECIALS.RAINBOW) && (_local3 != -1))) {
_local5++;
if (_local3 == SPECIALS.RAINBOW) {
_local3 = gameArray[_local2][_local4].OUTER_VALUE;
}
} else {
if (_local5 >= MIN_COMBO_LENGTH) {
registerCombo(_local2, _local4, _local5, "v", COMBO_TYPES.COLOR);
}
var _local6 = gameArray[_local2][_local4 - 1];
while ((_local6.OUTER_VALUE == SPECIALS.RAINBOW) && (_local4 < GAME_ARRAY_HEIGHT)) {
_local4--;
_local6 = gameArray[_local2][_local4 - 1];
}
_local3 = gameArray[_local2][_local4].OUTER_VALUE;
_local5 = 1;
}
_local4++;
}
_local5 = 1;
_local3 = -1;
_local2++;
}
var _local4 = 0;
while (_local4 < GAME_ARRAY_HEIGHT) {
_local2 = 0;
while (_local2 < (GAME_ARRAY_WIDTH + 1)) {
if (((gameArray[_local2][_local4].OUTER_VALUE == _local3) || (gameArray[_local2][_local4] && (_local3 == SPECIALS.RAINBOW))) || ((gameArray[_local2][_local4].OUTER_VALUE == SPECIALS.RAINBOW) && (_local3 != -1))) {
_local5++;
if (_local3 == SPECIALS.RAINBOW) {
_local3 = gameArray[_local2][_local4].OUTER_VALUE;
}
} else {
if (_local5 >= MIN_COMBO_LENGTH) {
registerCombo(_local2, _local4, _local5, "h", COMBO_TYPES.COLOR);
}
var _local6 = gameArray[_local2 - 1][_local4];
while ((_local6.OUTER_VALUE == SPECIALS.RAINBOW) && (_local2 < GAME_ARRAY_WIDTH)) {
_local2--;
_local6 = gameArray[_local2 - 1][_local4];
}
_local3 = gameArray[_local2][_local4].OUTER_VALUE;
_local5 = 1;
}
_local2++;
}
_local5 = 1;
_local3 = -1;
_local4++;
}
if (removeList.length > 0) {
this.isRemoving = true;
killTaggedBlocks();
} else if (needsNewBlocks()) {
game.feedNewBlocks();
}
};
this.feedNewBlocks = function () {
var _local4;
var _local6 = 0;
var _local2 = 0;
while (_local2 < GAME_ARRAY_WIDTH) {
_local4 = 0;
if (gameArray[_local2].blockCount < GAME_ARRAY_HEIGHT) {
var _local3 = 0;
while (_local3 < GAME_ARRAY_HEIGHT) {
if (!gameArray[_local2][_local3]) {
_local4++;
} else if (_local4 > 0) {
sprites.swapZIndex(gameArray[_local2][_local3], ("1" + (_local3 - _local4)) + _local2);
}
_local3++;
}
}
_local4 = 0;
while (gameArray[_local2].blockCount < GAME_ARRAY_HEIGHT) {
var _local5 = this.getFeedBlockObject();
this.pushBlock(_local2, _local5, GAME_ARRAY_HEIGHT + _local4, ("1" + gameArray[_local2].blockCount) + _local2);
_local4++;
}
_local6 = Math.max(_local4, _local6);
_local2++;
}
if (_local6 > 0) {
moveDownBlocks();
}
};
this.setGameOver = function (reason) {
tryGameOver = true;
if (this.gameOver) {
return(undefined);
}
deSelectBlock();
gameOverreason = reason;
var _local3 = 0;
while (_local3 < GAME_ARRAY_WIDTH) {
var _local2 = 0;
while (_local2 < GAME_ARRAY_HEIGHT) {
tmpSprite = gameArray[_local3][_local2];
if (tmpSprite) {
tmpSprite.onPress = none;
}
_local2++;
}
_local3++;
}
this.setGameOver2();
};
this.setGameOver2 = function () {
if (this.gameOver) {
return(undefined);
}
if (this.droppingBlockCnt > 0) {
return(undefined);
}
if (this.sliding == true) {
return(undefined);
}
if (this.isRemoving == true) {
return(undefined);
}
game.evaluateEvent({action:"bonus"});
this.gameOver = true;
new GameOverAnimation(gameArray);
};
this.getScore = function () {
return(this.score.getScore());
};
this.evaluateEvent = function (props) {
if (gameOver) {
return(undefined);
}
log.logEvent(props);
return(this.score.evaluateEvent(props));
};
this.toggleSound = function () {
this.gui.toggleSound();
soundFx.toggleOnOff();
};
this.generateMagicBall = function () {
var _local3 = new Score();
var _local2 = log.getLog();
var _local1 = 0;
while (_local1 < _local2.length) {
_local3.evaluateEvent(_local2[_local1]);
_local1++;
}
var _local4 = _local3.getScore();
gameResult = _local4;
fscommand ("gameOver", String(_local4));
};
}
function main() {
if (_gameStarted) {
return(undefined);
}
_gameStarted = true;
game = new Game("SilverScreen");
game.initialize();
}
sprites = new Sprites();
events = new Events();
soundFx = new SoundFx();
random = new Random();
var GAME_ARRAY_POS_X = 145;
var GAME_ARRAY_POS_Y = 12;
var GAME_ARRAY_WIDTH = 9;
var GAME_ARRAY_HEIGHT = 9;
var BLOCK_WIDTH = 51;
var BLOCK_HEIGHT = 40;
var NUMBER_OF_COLORS = 6;
var INSIDE_OFFSET_X = 8.8;
var INSIDE_OFFSET_Y = 21;
var BLOCK_DROP_START_Y = -40;
var MIN_COMBO_LENGTH = 3;
var MOUSE_OVER_BRIGHTNESS = 40;
var CLICK_BRIGHTNESS = -20;
var BLOCK_STATES = {INITIAL:"initial", SOLID:"solid", BOMB:"bomb"};
var BLOCK_TYPES = {NORMAL:"normal", RAINBOW:"rainbow", BOMB:"bomb"};
var BLOCK_SUFFIX = {FRAME:"_frame", INSIDE:"_inside", SOLID:"_solid", EXIT:"_exit", CLEAR_TO:"_clear2", SWITCH_TO:"_switch2"};
var BLOCK_COLORS = ["T", "G", "P", "B", "R", "Y"];
var SPECIALS = {RAINBOW:"W", BOMB:"I"};
var COMBO_TYPES = {COLOR:"color", BOMB:"bomb", CROSS:"cross"};
var gameResult = undefined;
var gameData = undefined;
var playTime = undefined;
Stage.showMenu = false;
Stage.scaleMode = "noScale";
stop();
main();
Symbol 20 MovieClip [Y_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 73 MovieClip [I_exit] Frame 11
stop();
if (this._parent.callback) {
this._parent.callback();
}
Symbol 154 MovieClip [W_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 154 MovieClip [W_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 154 MovieClip [W_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 154 MovieClip [W_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 154 MovieClip [W_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 154 MovieClip [W_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 161 MovieClip [W_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 171 MovieClip [W_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 181 MovieClip [R_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 187 MovieClip [B_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 193 MovieClip [P_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 199 MovieClip [G_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 205 MovieClip [T_exit] Frame 7
stop();
if (this.callback) {
this.callback();
}
Symbol 269 MovieClip [B_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 269 MovieClip [B_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 269 MovieClip [B_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 269 MovieClip [B_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 269 MovieClip [B_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 269 MovieClip [B_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 324 MovieClip [P_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 324 MovieClip [P_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 324 MovieClip [P_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 324 MovieClip [P_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 324 MovieClip [P_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 324 MovieClip [P_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 379 MovieClip [G_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 379 MovieClip [G_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 379 MovieClip [G_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 379 MovieClip [G_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 379 MovieClip [G_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 379 MovieClip [G_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 389 MovieClip [B_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 399 MovieClip [P_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 409 MovieClip [G_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 466 MovieClip [Y_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 466 MovieClip [Y_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 466 MovieClip [Y_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 466 MovieClip [Y_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 466 MovieClip [Y_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 466 MovieClip [Y_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 521 MovieClip [R_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 521 MovieClip [R_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 521 MovieClip [R_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 521 MovieClip [R_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 521 MovieClip [R_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 521 MovieClip [R_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 576 MovieClip [T_switch2] Frame 9
stop();
if (this.callback) {
this.callback();
}
Symbol 576 MovieClip [T_switch2] Frame 18
stop();
if (this.callback) {
this.callback();
}
Symbol 576 MovieClip [T_switch2] Frame 27
stop();
if (this.callback) {
this.callback();
}
Symbol 576 MovieClip [T_switch2] Frame 36
stop();
if (this.callback) {
this.callback();
}
Symbol 576 MovieClip [T_switch2] Frame 45
stop();
if (this.callback) {
this.callback();
}
Symbol 576 MovieClip [T_switch2] Frame 54
stop();
if (this.callback) {
this.callback();
}
Symbol 596 MovieClip [Y_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 606 MovieClip [R_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 616 MovieClip [T_clear2] Frame 10
stop();
if (this.callback) {
this.callback();
}
Symbol 658 MovieClip Frame 1
stop();
Symbol 658 MovieClip Frame 2
stop();