Symbol 21 MovieClip [Tear] Frame 1
#initclip 28
Object.registerClass("Tear", com.king.farmmatch.Tear);
#endinitclip
Symbol 124 MovieClip Frame 1
function onEnterFrame() {
var _local2 = getTimer() - startTime;
var _local1 = int((_local2 / 1000) * 8);
gotoAndStop((_local1 % 4) + 1);
}
var startTime = getTimer();
Symbol 132 MovieClip Frame 1
function onEnterFrame() {
var _local2 = getTimer() - startTime;
var _local1 = int(((_local2 / 1000) * 30) + offset);
light.gotoAndStop((_local1 % 80) + 1);
}
var startTime = getTimer();
var offset = (Math.random() * 80);
Symbol 160 MovieClip [Poof] Frame 1
#initclip 19
Object.registerClass("Poof", com.king.farmmatch.Poof);
#endinitclip
Symbol 182 MovieClip [Instructions] Frame 1
#initclip 20
Object.registerClass("Instructions", com.king.farmmatch.Instructions);
#endinitclip
Symbol 183 MovieClip [TearSpawner] Frame 1
#initclip 21
Object.registerClass("TearSpawner", com.king.farmmatch.TearSpawner);
#endinitclip
Symbol 212 MovieClip [TimeChippie] Frame 1
#initclip 22
Object.registerClass("TimeChippie", com.king.farmmatch.TimeChippie);
#endinitclip
Symbol 213 MovieClip [Chippie] Frame 1
#initclip 23
Object.registerClass("Chippie", com.king.farmmatch.Chippie);
#endinitclip
Symbol 217 MovieClip [TilePlaceholder] Frame 1
#initclip 24
Object.registerClass("TilePlaceholder", com.king.farmmatch.TilePlaceholder);
#endinitclip
Symbol 221 MovieClip [GameArea] Frame 1
#initclip 25
Object.registerClass("GameArea", com.king.farmmatch.GameArea);
#endinitclip
Symbol 232 MovieClip [LevelTimer] Frame 1
#initclip 26
Object.registerClass("LevelTimer", com.king.farmmatch.LevelTimer);
#endinitclip
Symbol 258 MovieClip [Background] Frame 1
#initclip 27
Object.registerClass("Background", com.king.farmmatch.Background);
#endinitclip
Symbol 331 MovieClip Frame 1
function setScore(score, won) {
this.won = won;
var _local2 = 0;
while (_local2 < 5) {
this["n" + _local2].gotoAndStop(1 + (won ? 0 : 10));
var _local3 = score % 10;
targetDigits[_local2] = _local3;
score = int(score / 10);
digits[_local2] = -9;
_local2++;
}
lastShowTime = getTimer();
}
function onEnterFrame() {
var _local4 = getTimer();
while ((_local4 - lastShowTime) > tickTime) {
lastShowTime = _local4;
var _local2 = 0;
while (_local2 < 5) {
if (digits[_local2] < targetDigits[_local2]) {
digits[_local2]++;
}
var _local3 = digits[_local2];
if (_local3 < 0) {
_local3 = 0;
}
this["n" + _local2].gotoAndStop((_local3 + 1) + (won ? 0 : 10));
_local2++;
}
}
}
var targetScore = 31337;
var currentScore = 0;
var digits = new Array(5);
var targetDigits = new Array(5);
var won = false;
var i = 0;
while (i < 5) {
digits[i] = -9;
targetDigits[i] = -9;
i++;
}
var lastShowTime = getTimer();
var tickTime = 166.666666666667;
Symbol 349 MovieClip Frame 1
function onEnterFrame() {
var _local1 = (int(getTimer() / 83.3333333333333) % 4) + 1;
pig0.gotoAndStop(_local1);
pig1.gotoAndStop(_local1);
cow0.gotoAndStop(_local1);
cow1.gotoAndStop(_local1);
}
Symbol 357 Button
on (press) {
_root.tileLayer.exitButtonPressed();
}
Symbol 364 Button
on (press) {
_root.tileLayer.soundButtonPressed();
}
Symbol 366 MovieClip [__Packages.com.king.farmmatch.Poof] Frame 0
class com.king.farmmatch.Poof extends MovieClip
{
var ts, ss, _rotation, xd, yd, _x, xStart, _y, yStart, startTime, gravity, side, pic, gotoAndStop, _xscale, _yscale, _alpha, removeMovieClip;
function Poof () {
super();
}
function init(x, y, d) {
if (d == undefined) {
d = (Math.random() * Math.PI) * 2;
}
var _local3 = d + (((Math.random() * Math.PI) * 2) / 20);
var _local2 = (Math.random() * 0.5) + 0.5;
ts = (Math.random() * 0.6) + 0.7;
ss = (Math.random() * 0.5) + 0.5;
_rotation = Math.random() * 360;
xd = Math.sin(_local3) * _local2;
yd = Math.cos(_local3) * _local2;
_x = (xStart = x + ((xd * 16) * _local2));
_y = (yStart = y + ((yd * 16) * _local2));
startTime = getTimer();
gravity = 0;
side = 0;
pic = int(Math.random() * 4);
gotoAndStop(pic + 1);
onEnterFrame();
}
function setGravity(icon) {
if (yd > 0) {
yd = -yd;
}
yd = yd * 4;
gotoAndStop(icon);
gravity = 2;
}
function setSpeed(speed) {
ts = ts * speed;
_rotation = 0;
}
function setTwirl(icon) {
ts = ts * 0.5;
xd = xd * 2;
yd = yd * 2;
side = 1;
gotoAndStop(icon);
}
function onEnterFrame() {
var _local2 = ((getTimer() - startTime) / 100) * ts;
var _local3 = Math.sqrt(_local2);
_local3 = _local3 * _local3;
_x = xStart + ((xd * _local2) * 5);
_y = (yStart + ((yd * _local2) * 5)) + (((_local2 * _local2) * gravity) * 1);
if (side > 0) {
_local3 = Math.sin(_local2 * 6);
_x = _x + ((_local3 * yd) * 2);
_y = _y - ((_local3 * xd) * 2);
}
_xscale = (_yscale = (100 - (_local2 * 12)) * ss);
_alpha = 100 - (_local2 * 12);
if ((_alpha <= 0) || (_xscale <= 0)) {
removeMovieClip();
}
}
}
Symbol 367 MovieClip [__Packages.com.king.farmmatch.Instructions] Frame 0
class com.king.farmmatch.Instructions extends MovieClip
{
var startTime, page, gotoAndStop;
function Instructions () {
super();
startTime = getTimer();
page = 1;
}
function onEnterFrame() {
var _local2 = getTimer() - startTime;
var _local3 = int(_local2 / 2176) % 3;
if (page == 2) {
_local3 = 3;
}
gotoAndStop((2 + (_local3 * 2)) + (int(_local2 / 272) & 1));
}
}
Symbol 368 MovieClip [__Packages.com.king.farmmatch.TearSpawner] Frame 0
class com.king.farmmatch.TearSpawner extends MovieClip
{
var lastTime, unprocessed, tearTick, attachMovie;
function TearSpawner () {
super();
lastTime = getTimer();
unprocessed = 0;
tearTick = 0;
}
function onEnterFrame() {
var _local4 = getTimer();
unprocessed = unprocessed + (_local4 - lastTime);
lastTime = _local4;
while (unprocessed > 100) {
unprocessed = unprocessed - 100;
if ((int(tearTick / 10) % 2) == 1) {
var _local2 = 0;
while (_local2 < 2) {
var _local3 = attachMovie("Tear", "tear" + td, td);
_local3.init((_local2 * Math.PI) - 1.3);
td = (td + 1) & 255;
_local2++;
}
}
tearTick++;
}
}
var td = 0;
}
Symbol 369 MovieClip [__Packages.com.king.farmmatch.TimeChippie] Frame 0
class com.king.farmmatch.TimeChippie extends MovieClip
{
static var allChippies;
var sign, chip, live;
function TimeChippie () {
super();
}
static function triggerRandom(value) {
allChippies[int(Math.random() * allChippies.length)].trigger(value);
}
function trigger(value) {
sign.text = value;
chip.c.score.num0.gotoAndStop(int(value % 10) + 1);
chip.c.score.num1.gotoAndStop(int((value / 10) % 10) + 1);
chip.c.score.num2.gotoAndStop(int((value / 100) % 10) + 1);
startTime = getTimer();
chip._rotation = (Math.random() * 20) - 10;
onEnterFrame = animate;
chip._visible = true;
chip.c.gotoAndStop(2);
live = true;
}
function onEnterFrame() {
if (initialized) {
return(undefined);
}
initialized = true;
sign = chip.c.sign;
chip._visible = false;
live = false;
chip._visible = false;
onEnterFrame = undefined;
if (allChippies == undefined) {
allChippies = new Array();
}
allChippies.push(this);
}
function animate() {
var _local2 = (getTimer() - startTime) / 2000;
if (_local2 > 0) {
if (_local2 > 1) {
startTime = -1;
onEnterFrame = undefined;
chip._visible = false;
live = false;
}
var _local3 = Math.sin(_local2 * Math.PI) * 270;
if (_local3 > 140) {
_local3 = 140;
}
chip.c._y = _local3;
}
}
var startTime = -1;
var initialized = false;
}
Symbol 370 MovieClip [__Packages.com.king.farmmatch.Chippie] Frame 0
class com.king.farmmatch.Chippie extends MovieClip
{
static var allChippies;
var sign, chip, live, _y, _xscale, _yscale;
function Chippie () {
super();
}
static function triggerRandom(value) {
allChippies[int(Math.random() * allChippies.length)].trigger(value);
}
function trigger(value) {
sign.text = value;
chip.c.score.num0.gotoAndStop(int(value % 10) + 1);
chip.c.score.num1.gotoAndStop(int((value / 10) % 10) + 1);
chip.c.score.num2.gotoAndStop(int((value / 100) % 10) + 1);
startTime = getTimer();
chip._rotation = (Math.random() * 20) - 10;
onEnterFrame = animate;
chip._visible = true;
chip.c.gotoAndStop(1);
live = true;
}
function onEnterFrame() {
if (initialized) {
return(undefined);
}
initialized = true;
sign = chip.c.sign;
chip._visible = false;
live = false;
chip._visible = false;
onEnterFrame = undefined;
if (allChippies == undefined) {
allChippies = new Array();
}
var _local2 = _y / 450;
_xscale = (_yscale = 50 + (_local2 * 50));
allChippies.push(this);
}
function animate() {
var _local2 = (getTimer() - startTime) / 1200;
if (_local2 > 0) {
if (_local2 > 1) {
startTime = -1;
onEnterFrame = undefined;
chip._visible = false;
live = false;
}
var _local3 = Math.sin(_local2 * Math.PI) * 270;
if (_local3 > 140) {
_local3 = 140;
}
chip.c._y = -_local3;
}
}
var startTime = -1;
var initialized = false;
}
Symbol 371 MovieClip [__Packages.com.king.farmmatch.TilePlaceholder] Frame 0
class com.king.farmmatch.TilePlaceholder extends MovieClip
{
var outline, pressListener, id;
function TilePlaceholder () {
super();
}
function init(pressListener, id) {
outline._visible = false;
this.pressListener = pressListener;
this.id = id;
}
function onPress() {
pressListener.tileClicked(id);
}
}
Symbol 372 MovieClip [__Packages.com.king.farmmatch.GameArea] Frame 0
class com.king.farmmatch.GameArea extends MovieClip
{
var currentChainVal, currentChain, clickQueue, hasPlayedTimeWarning, state, stateStartTime, communicator, unhappyMeters, remainingCards, _quality, level, score, tileHolders, thPile, nextStateTime, random, lastPairTime, levelStartTime, scorePerPair, timelimit, timeBonus, deck, tiles, tileLayer, tilePointer, revealedCards, selected;
function GameArea () {
super();
currentChainVal = -1;
currentChain = 0;
clickQueue = new Array();
_global.animUntil = getTimer();
hasPlayedTimeWarning = false;
state = STATE_INIT;
stateStartTime = getTimer();
communicator = new com.king.farmmatch.Communicator();
_root.infoPanel.onPress = mx.utils.Delegate.create(this, infoPanelPressed);
_root.infoPanel.bg.gotoAndStop(1);
_root.infoPanel.result._visible = false;
_root.infoPanel.scoreMeter._visible = false;
unhappyMeters = new Array(8);
_root.infoPanel.danceAnimation._visible = false;
_root.levelIndicator._visible = false;
_root.bg.setPage(1);
_root.bg2.setPage(2);
_root.bg2._visible = false;
remainingCards.text = "";
}
function fullscreenButtonPressed(e) {
if (Stage.displayState != "fullscreen") {
Stage.displayState = "fullscreen";
_quality = "medium";
} else {
Stage.displayState = "normal";
_quality = "medium";
}
}
function init() {
level = 0;
score = 0;
tileHolders = new Array(20);
var _local4 = 0;
while (_local4 < 20) {
tileHolders[_local4] = this["th" + _local4];
tileHolders[_local4].init(this, _local4);
_local4++;
}
thPile._visible = false;
communicator.parseGameData(_root.gameData);
communicator.gameStarted();
state = STATE_SHOW_INSTRUCTIONS;
stateStartTime = getTimer();
nextStateTime = getTimer() + 20000;
_root.infoPanel._visible = true;
_quality = "high";
random = new src.util.Random(communicator.randomSeed);
com.king.farmmatch.Sounds.get("introSound").play();
_root.scoreText.text = _global.textMappings.score;
_root.timeText.text = _global.textMappings.time;
_root.levelText.text = _global.textMappings.level;
_root.levelMeter.text = "1";
_root.soundButtonText = _global.textMappings.sound_on;
_root.exitButtonText = _global.textMappings.exit_game;
_root.infoPanel.title.text = _global.textMappings.instructions_title;
_root.infoPanel.text.text = _global.textMappings.instructions;
_root.timer.setProgress(0);
_root.timer.init();
}
function nextLevel(time) {
currentChainVal = -1;
currentChain = 0;
lastPairTime = 0;
_root.timer.init();
levelStartTime = time;
_root.levelMeter.text = "" + (level + 1);
communicator.sendStartLevel(levelStartTime);
_root.bg.setPage(level + 1);
if ((level + 2) <= 3) {
_root.bg2.setPage(level + 2);
} else {
_root.bg2.setPage(3);
}
_root.bg2._visible = false;
scorePerPair = PAIR_SCORES[level];
timelimit = LEVEL_TIMES[level];
timeBonus = 500;
var _local3 = 0;
while (_local3 < 8) {
unhappyMeters[_local3] = 0;
_local3++;
}
deck = new com.king.farmmatch.Deck(level, random);
tiles = new Array(deck.size);
var _local4 = 0;
while (_local4 < deck.size) {
tiles[_local4] = new com.king.farmmatch.Tile(this, tileLayer, thPile._x + 11, thPile._y + 11, deck.size - _local4, deck.pop());
_local4++;
}
tilePointer = 0;
_local4 = 0;
while (_local4 < 20) {
tiles[_local4].firstFlyTo(tileHolders[_local4]._x + 37, tileHolders[_local4]._y + 37, _local4 * 100, false);
tileHolders[_local4].tile = tiles[_local4];
tilePointer++;
_local4++;
}
_local4 = 0;
while (_local4 < 20) {
updateMood(_local4);
_local4++;
}
level++;
revealedCards = 0;
remainingCards.text = "" + deck.size;
clickQueue = new Array();
}
function infoPanelPressed() {
if (getTimer() > (stateStartTime + 250)) {
nextStateTime = getTimer();
}
}
function updateMood(id) {
if (this["th" + id].tile != undefined) {
if (unhappyMeters[this["th" + id].tile.value] > 12) {
this["th" + id].tile.setMood(com.king.farmmatch.Tile.MOOD_SAD);
} else {
var _local4 = id % 5;
var _local3 = false;
if (((_local4 > 0) && (this["th" + (id - 1)].tile != undefined)) && (this["th" + (id - 1)].tile.matches(this["th" + id].tile))) {
_local3 = true;
}
if (((_local4 < 4) && (this["th" + (id + 1)].tile != undefined)) && (this["th" + (id + 1)].tile.matches(this["th" + id].tile))) {
_local3 = true;
}
this["th" + id].tile.setMood((_local3 ? (com.king.farmmatch.Tile.MOOD_HAPPY) : (com.king.farmmatch.Tile.MOOD_IDLE)));
}
}
}
function tileClicked(id) {
if (getTimer() < _global.animUntil) {
clickQueue.push(id);
return(undefined);
}
var _local5 = getTimer();
var _local8 = score;
if (state != STATE_PLAY) {
return(undefined);
}
if (selected != undefined) {
this["th" + selected].outline._visible = false;
updateMood(selected);
}
if (selected == id) {
selected = undefined;
} else {
var _local6 = (id % 5) - (selected % 5);
var _local7 = int(id / 5) - int(selected / 5);
if (tileHolders[id].tile == undefined) {
selected = undefined;
} else if (((((selected != undefined) && (_local6 >= -1)) && (_local7 >= -1)) && (_local6 <= 1)) && (_local7 <= 1)) {
clickPair(_local5, selected, id);
} else {
selected = id;
}
}
if (selected != undefined) {
this["th" + selected].outline._visible = true;
this["th" + selected].tile.setMood(com.king.farmmatch.Tile.MOOD_SELECTED);
}
checkStatus(_local5);
communicator.clickAt(id, _local5, score - _local8);
if (hasWon()) {
com.king.farmmatch.Sounds.get("music0").stop();
com.king.farmmatch.Sounds.get("music1").stop();
com.king.farmmatch.Sounds.get("music2").stop();
com.king.farmmatch.Sounds.get("timeRunningOutSound").stop();
hasPlayedTimeWarning = false;
remainingCards.text = "";
if ((!_global.shortGameMode) && (level < 3)) {
com.king.farmmatch.Sounds.get("levelCompleted").play();
_root.levelIndicator.gotoAndStop(level + 1);
_root.bg2.visible = true;
state = STATE_SHOW_LEVEL_SPLASH;
stateStartTime = getTimer();
nextStateTime = getTimer() + 3500;
} else {
win();
}
} else if (!hasPair()) {
com.king.farmmatch.Sounds.get("music0").stop();
com.king.farmmatch.Sounds.get("music1").stop();
com.king.farmmatch.Sounds.get("music2").stop();
noMorePairs();
}
}
function clickPair(time, from, to) {
if (((tileHolders[from].tile != undefined) && (tileHolders[to].tile != undefined)) && (tileHolders[from].tile.matches(tileHolders[to].tile))) {
var _local7 = 1;
_local7 = _local7 * tileHolders[from].tile.multiplier;
_local7 = _local7 * tileHolders[to].tile.multiplier;
var _local12 = tileHolders[from].tile.value;
var _local10 = tileHolders[to].tile.value;
var _local3 = _local12;
if (_local3 == 8) {
_local3 = _local10;
}
if (currentChainVal == _local3) {
currentChain++;
} else {
currentChainVal = _local3;
currentChain = 0;
}
unhappyMeters[_local3] = 0;
com.king.farmmatch.Sounds.get("Animal" + _local3).play();
var _local8 = ((tileHolders[from]._x + 37) + (tileHolders[to]._x + 37)) / 2;
var _local9 = ((tileHolders[from]._y + 37) + (tileHolders[to]._y + 37)) / 2;
tileHolders[from].tile.dieTo(_local8, _local9);
tileHolders[to].tile.dieTo(_local8, _local9);
if (_local7 > 1) {
tileHolders[from].tile.deathAnim = _local7 - 1;
}
tileHolders[from].tile = undefined;
tileHolders[to].tile = undefined;
selected = undefined;
var _local6 = 0;
_local6 = _local6 + scorePerPair;
_local6 = _local6 + (25 * currentChain);
var _local13 = time - lastPairTime;
var _local11 = 5 - int(_local13 / 500);
if (_local11 > 0) {
_local6 = _local6 + _local11;
}
lastPairTime = time;
_local6 = _local6 * _local7;
if (_local7 > 1) {
com.king.farmmatch.Sounds.get("bonusSound").play();
}
score = score + _local6;
scoreGained = scoreGained + _local6;
_root.scoreMeter.text = score;
com.king.farmmatch.Chippie.triggerRandom(_local6);
if ((_local12 == 8) || (_local10 == 8)) {
com.king.farmmatch.Sounds.get("rhinoSound").play();
removeAll(_local3, _local8, _local9);
}
pack();
} else {
selected = to;
}
}
function removeAll(value, xMid, yMid) {
var _local2 = 0;
while (_local2 < tileHolders.length) {
if ((tileHolders[_local2].tile != undefined) && (tileHolders[_local2].tile.value == value)) {
tileHolders[_local2].tile.dieTo(xMid, yMid);
tileHolders[_local2].tile = undefined;
}
_local2++;
}
var _local4 = 0;
var _local3 = new Array();
_local2 = tilePointer;
while (_local2 < tiles.length) {
if (tiles[_local2].value == value) {
tiles[_local2].dieTo(xMid, yMid);
_local3.push(tiles[_local2]);
tiles.splice(_local2--, 1);
_local4++;
}
_local2++;
}
_local2 = 0;
while (_local2 < _local4) {
tiles.splice(tilePointer++, 0, _local3[_local2]);
_local2++;
}
}
function checkStatus(time) {
if (countTiles() == 1) {
tileHolders[0].tile.dieTo(32, 32);
tileHolders[0].tile.deathAnim = -1;
tileHolders[0].tile = undefined;
score = score + 500;
scoreGained = scoreGained + 500;
}
if (hasWon()) {
var _local4 = ((time - levelStartTime) - 999) / 1000;
var _local5 = 1 - (_local4 / timelimit);
var _local3 = int(_local5 * timeBonus);
timeBonusGained = timeBonusGained + _local3;
score = score + _local3;
com.king.farmmatch.TimeChippie.triggerRandom(_local3);
_root.debugText.text = (((("Time bonus: " + _local4) + "/ ") + timelimit) + " -> ") + int(_local5 * timeBonus);
_root.scoreMeter.text = score;
}
}
function countTiles() {
var _local3 = 0;
var _local2 = 0;
while (_local2 < 20) {
if (tileHolders[_local2].tile != undefined) {
_local3++;
}
_local2++;
}
return(_local3);
}
function hasWon() {
var _local2 = 0;
while (_local2 < 20) {
if (tileHolders[_local2].tile != undefined) {
return(false);
}
_local2++;
}
return(true);
}
function hasPair() {
var _local5 = 0;
while (_local5 < 5) {
var _local4 = 0;
while (_local4 < 4) {
var _local7 = (_local4 * 5) + _local5;
if (tileHolders[_local7].tile != undefined) {
var _local3 = _local5 - 1;
while (_local3 <= (_local5 + 1)) {
var _local2 = _local4 - 1;
while (_local2 <= (_local4 + 1)) {
var _local6 = (_local2 * 5) + _local3;
if (((((((_local3 >= 0) && (_local2 >= 0)) && (_local3 < 5)) && (_local2 < 4)) && ((_local3 != _local5) || (_local2 != _local4))) && (tileHolders[_local6].tile != undefined)) && (tileHolders[_local6].tile.matches(tileHolders[_local7].tile))) {
return(true);
}
_local2++;
}
_local3++;
}
}
_local4++;
}
_local5++;
}
return(false);
}
function pack() {
var _local2 = 0;
var _local5 = 0;
var _local4 = 0;
while (_local4 < 20) {
if (tileHolders[_local4].tile == undefined) {
_local2++;
} else if (_local2 > 0) {
_local5++;
tileHolders[_local4 - _local2].tile = tileHolders[_local4].tile;
tileHolders[_local4].tile = undefined;
tileHolders[_local4 - _local2].tile.flyTo(tileHolders[_local4 - _local2]._x + 37, tileHolders[_local4 - _local2]._y + 37, _local5 * 50);
}
_local4++;
}
_local4 = 20 - _local2;
while (_local4 < 20) {
if (tilePointer < deck.size) {
_local5++;
tiles[tilePointer].firstFlyTo(tileHolders[_local4]._x + 37, tileHolders[_local4]._y + 37, _local5 * 50, true);
tileHolders[_local4].tile = tiles[tilePointer];
tilePointer++;
}
_local4++;
}
var _local3 = 0;
while (_local3 < 8) {
unhappyMeters[_local3]++;
_local3++;
}
_local4 = 0;
while (_local4 < 20) {
updateMood(_local4);
_local4++;
}
}
function onEnterFrame() {
switch (state) {
case STATE_INIT :
if (DEBUG_MODE) {
_root.gameData = DEBUG_GAME_DATA;
}
if (_root.gameData != undefined) {
init();
return(undefined);
}
break;
case STATE_SHOW_INSTRUCTIONS :
_root.hider._visible = false;
var _local7 = int(((nextStateTime - getTimer()) + 999) / 1000);
if (_local7 <= 10) {
_root.infoPanel.title.text = _global.textMappings.instructions_title_2;
_root.infoPanel.text.text = _global.textMappings.instructions_2;
_root.infoPanel.instructions.page = 2;
}
if (_local7 <= 0) {
com.king.farmmatch.Sounds.get("introSound").stop();
_root.infoPanel._visible = false;
_quality = "medium";
_root.levelIndicator.gotoAndStop(level + 1);
com.king.farmmatch.Sounds.get("levelCompleted").play();
_root.bg2.visible = true;
state = STATE_SHOW_LEVEL_SPLASH;
stateStartTime = getTimer();
nextStateTime = getTimer() + 3500;
_local7 = 0;
}
_root.infoPanel.timer.text = _global.textMappings.game_starts_in.split("[0]").join(_local7);
break;
case STATE_SHOW_LEVEL_SPLASH :
var _local8 = (getTimer() - stateStartTime) / (nextStateTime - stateStartTime);
_root.timer.resetProgress(_local8);
if (level > 0) {
_root.bg2._alpha = _local8 * 100;
_root.bg2._visible = true;
} else {
_root.bg2._visible = false;
}
var _local6 = (getTimer() - stateStartTime) / 6;
if (_local6 > 100) {
_local6 = 100;
}
_root.levelIndicator._visible = true;
_root.levelIndicator._xscale = (_root.levelIndicator._yscale = (_local6 * _local6) / 100);
_root.levelIndicator._rotation = (100 - _local6) * 6;
if ((nextStateTime - getTimer()) <= 0) {
_root.levelIndicator._visible = false;
state = STATE_PLAY;
com.king.farmmatch.Sounds.get("music" + level).playLooping();
com.king.farmmatch.Sounds.get("music" + level).setVolume(50);
stateStartTime = getTimer();
nextLevel(stateStartTime);
_local7 = 0;
_root.bg2.visible = false;
}
_root.infoPanel.timer.text = _global.textMappings.game_starts_in.split("[0]").join(_local7);
break;
case STATE_PLAY :
if ((clickQueue.length > 0) && (getTimer() > _global.animUntil)) {
var _local4 = 0;
while (_local4 < clickQueue.length) {
tileClicked(clickQueue[_local4]);
_local4++;
}
clickQueue = new Array();
return(undefined);
}
var _local11 = ((getTimer() - levelStartTime) - 999) / 1000;
var _local5 = int(timelimit - _local11);
var _local9 = int(_local5 / 60);
_root.timeMeter.text = (((((_local9 < 10) ? "0" : "") + _local9) + ":") + (((_local5 % 60) < 10) ? "0" : "")) + (_local5 % 60);
var _local10 = ((getTimer() - levelStartTime) / 1000) / timelimit;
_root.timer.setProgress(_local10);
src.util.TimeVerifier.checkTime();
if ((_local5 <= 5) && (!hasPlayedTimeWarning)) {
hasPlayedTimeWarning = true;
com.king.farmmatch.Sounds.get("timeRunningOutSound").play();
_root.timer.warn();
}
if (_local5 <= 0) {
com.king.farmmatch.Sounds.get("music0").stop();
com.king.farmmatch.Sounds.get("music1").stop();
com.king.farmmatch.Sounds.get("music2").stop();
_local5 = 0;
com.king.farmmatch.Sounds.get("timeRunningOutSound").stop();
outOfTime();
_root.timer.lose();
}
break;
case STATE_GAME_OVER :
if ((getTimer() > (stateStartTime + 1000)) && (shouldPlayLoseMusic)) {
com.king.farmmatch.Sounds.get("winSound").play();
shouldPlayLoseMusic = false;
}
if (getTimer() > (stateStartTime + 1000)) {
_root.infoPanel._visible = true;
_quality = "high";
}
_local7 = int(((nextStateTime - getTimer()) + 999) / 1000);
if (_local7 <= 0) {
communicator.gameQuit();
state = STATE_GAME_QUIT;
stateStartTime = getTimer();
_local7 = 0;
}
_root.infoPanel.timer.text = _global.textMappings.game_ends_in.split("[0]").join(_local7);
}
}
function cardFlipped() {
revealedCards++;
if (deck.size == revealedCards) {
remainingCards.text = "";
} else {
remainingCards.text = "" + (deck.size - revealedCards);
}
}
function win() {
com.king.farmmatch.Sounds.get("winSound").play();
_root.infoPanel.title.text = _global.textMappings.win_title;
_root.infoPanel.text.text = "";
_root.infoPanel.danceAnimation._visible = true;
_root.infoPanel.instructions._visible = false;
communicator.gameEnd(score);
state = STATE_GAME_OVER;
stateStartTime = getTimer();
nextStateTime = getTimer() + 7000;
showFinalScores(true);
}
function noMorePairs() {
_root.infoPanel.bg.gotoAndStop(2);
com.king.farmmatch.Sounds.get("loseSound").play();
shouldPlayLoseMusic = true;
_root.infoPanel.title.text = _global.textMappings.out_of_moves_title;
_root.infoPanel.text.text = _global.textMappings.out_of_moves_text;
_root.infoPanel.instructions._visible = false;
_root.infoPanel.result._y = _root.infoPanel.result._y + 50;
communicator.gameEnd(score);
state = STATE_GAME_OVER;
stateStartTime = getTimer();
nextStateTime = getTimer() + 7000;
showFinalScores(false);
_root.infoPanel._visible = false;
_quality = "medium";
}
function outOfTime() {
_root.infoPanel.bg.gotoAndStop(2);
com.king.farmmatch.Sounds.get("loseSound").play();
shouldPlayLoseMusic = true;
var _local4 = 0;
while (_local4 < 5) {
var _local5 = _root.attachMovie("Poof", "poof" + _local4, 5000 + _local4);
_local5.init((_root.timer._x + _root.timer.head._x) + 20, _root.timer._y + _root.timer.head._y, ((_local4 * Math.PI) * 2) / 5);
_local5.setGravity(7);
_local4++;
}
remainingCards.text = "";
_root.infoPanel._visible = true;
_quality = "high";
_root.infoPanel.title.text = _global.textMappings.out_of_time_title;
_root.infoPanel.text.text = _global.textMappings.out_of_time_text;
_root.infoPanel.instructions._visible = false;
_root.infoPanel.result._y = _root.infoPanel.result._y + 50;
communicator.gameEnd(score);
state = STATE_GAME_OVER;
stateStartTime = getTimer();
nextStateTime = getTimer() + 7000;
showFinalScores(false);
_root.infoPanel._visible = false;
_quality = "medium";
}
function showFinalScores(won) {
_root.endScoreText = (_global.textMappings.score_label + "\r") + _global.textMappings.time_bonus_label;
_root.finalScoreText = _global.textMappings.total_score_label;
_root.infoPanel.scoreMeter._visible = true;
_root.infoPanel.scoreMeter.setScore(score, won);
_root.scoreValueText = (scoreGained + "\r") + timeBonusGained;
_root.finalScoreValueText = "" + (scoreGained + timeBonusGained);
_root.infoPanel.result._visible = true;
}
function soundButtonPressed() {
com.king.farmmatch.Sounds.toggleSound();
soundOn = !soundOn;
_root.soundButtonText = (soundOn ? (_global.textMappings.sound_on) : (_global.textMappings.sound_off));
}
function exitButtonPressed() {
if ((state != STATE_GAME_OVER) && (state != STATE_GAME_QUIT)) {
com.king.farmmatch.Sounds.get("music0").stop();
com.king.farmmatch.Sounds.get("music1").stop();
com.king.farmmatch.Sounds.get("music2").stop();
com.king.farmmatch.Sounds.get("timeRunningOutSound").stop();
_root.infoPanel.bg.gotoAndStop(2);
com.king.farmmatch.Sounds.get("loseSound").play();
shouldPlayLoseMusic = true;
_root.infoPanel.title.text = _global.textMappings.game_exited_title;
_root.infoPanel.text.text = _global.textMappings.game_exited_text;
_root.infoPanel.instructions._visible = false;
_root.infoPanel.result._y = _root.infoPanel.result._y + 50;
communicator.gameEnd(score);
state = STATE_GAME_OVER;
stateStartTime = getTimer();
nextStateTime = getTimer() + 5000;
showFinalScores(false);
}
}
static var DEBUG_MODE = true;
static var PAIR_SCORES = [100, 110, 120];
static var LEVEL_TIMES = [60, 120, 180];
static var STATE_INIT = 0;
static var STATE_SHOW_INSTRUCTIONS = 1;
static var STATE_SHOW_LEVEL_SPLASH = 2;
static var STATE_PLAY = 3;
static var STATE_GAME_OVER = 4;
static var STATE_GAME_QUIT = 5;
var DEBUG_GAME_DATA = "<gamedata randomseed=\"930021799\" timelimit=\"300\"> <text id=\"sound_off\">Sound off</text> <text id=\"sound_on\">Sound on</text> <text id=\"exit_game\">Exit game</text> <text id=\"instructions_title\">GAME INSTRUCTIONS</text> <text id=\"instructions\">THIS IS THE DEBUG VERSION THIS IS THE DEBUG VERSION THIS IS THE DEBUG VERSION</text> <text id=\"instructions_title_2\">GAME INSTRUCTIONS Part 2</text> <text id=\"instructions_2\">Combining the Magic White Rhino with an animal clears all animals of that type left. Use it to get out of a tight spot, but it lowers your score. If you manage to complete the level without using it you get a bonus.</text> <text id=\"fullscreen\">FULLSCREEN</text> <text id=\"windowed\">WINDOWED</text> <text id=\"time\">TIME</text> <text id=\"level\">LEVEL</text> <text id=\"score\">SCORE</text> <text id=\"game_starts_in\">The game will start in [0] seconds</text> <text id=\"game_ends_in\">The game will end in [0] seconds</text> <text id=\"win_title\">YOU WIN</text> <text id=\"win_text\">You won! Yay!</text> <text id=\"out_of_moves_title\">OUT OF MOVES</text> <text id=\"out_of_moves_text\">There are no more possible moves!</text> <text id=\"out_of_time_title\">OUT OF TIME</text> <text id=\"out_of_time_text\">You ran out of time!</text> <text id=\"score_label\">Score:</text> <text id=\"time_bonus_label\">Time Bonus:</text> <text id=\"total_score_label\">Total Score:</text> <text id=\"game_exited_title\">Game exited</text> <text id=\"game_exited_text\">You quit the game</text></gamedata>";
var scoreGained = 0;
var timeBonusGained = 0;
var shouldPlayLoseMusic = false;
var soundOn = true;
}
Symbol 373 MovieClip [__Packages.com.king.farmmatch.Communicator] Frame 0
class com.king.farmmatch.Communicator
{
var randomSeed;
function Communicator () {
}
function gameStarted() {
fscommand ("gameStart");
fscommand ("playData", ((CMD_INIT + ",") + VERSION_NUM) + "=0");
}
function gameEnd(score) {
if (!hasSentGameEnd) {
hasSentGameEnd = true;
fscommand ("gameEnd", score);
}
}
function gameQuit() {
if (!hasSentGameOver) {
hasSentGameOver = true;
fscommand ("gameQuit");
}
}
function sendEndGamePressed() {
fscommand ("playData", CMD_END_GAME_PRESSED + "=0");
}
function sendStartLevel(startTime) {
fscommand ("playData", ((CMD_START_LEVEL + ",") + startTime) + "=0");
}
function clickAt(id, time, scoreGained) {
fscommand ("playData", (((((CMD_CLICK_AT + ",") + id) + " ") + time) + "=") + scoreGained);
}
function parseGameData(gameData) {
var _local6 = new XML(_root.gameData);
_global.shortGameMode = new String(_local6.childNodes[0].attributes.mode) == "short";
_global.textMappings = new Object();
var _local5 = _local6.childNodes[0].childNodes;
randomSeed = new Number(_local6.childNodes[0].attributes.randomseed).valueOf();
var _local4 = 0;
while (_local4 < _local5.length) {
if (_local5[_local4].nodeName == "text") {
_global.textMappings[_local5[_local4].attributes.id] = new String(_local5[_local4].firstChild.nodeValue);
_root.debugText.text = _root.debugText.text + ((("_global.textMappings[\"" + _local5[_local4].attributes.id) + "\"] = ") + new String(_local5[_local4].firstChild.nodeValue + "\r"));
}
_local4++;
}
}
var hasSentGameEnd = false;
var hasSentGameOver = false;
static var VERSION_NUM = 0;
static var CMD_INIT = 442;
static var CMD_START_LEVEL = 787;
static var CMD_CLICK_AT = 271;
static var CMD_END_GAME_PRESSED = 602;
}
Symbol 374 MovieClip [__Packages.mx.utils.Delegate] Frame 0
class mx.utils.Delegate extends Object
{
var func;
function Delegate (f) {
super();
func = f;
}
static function create(obj, func) {
var _local2 = function () {
var _local2 = arguments.callee.target;
var _local3 = arguments.callee.func;
return(_local3.apply(_local2, arguments));
};
_local2.target = obj;
_local2.func = func;
return(_local2);
}
function createDelegate(obj) {
return(create(obj, func));
}
}
Symbol 375 MovieClip [__Packages.src.util.Random] Frame 0
class src.util.Random
{
var mta, mti, lastSeed;
function Random (aSeed) {
mta = new Array(N);
mti = N + 1;
if (aSeed != undefined) {
init_genrand(aSeed);
}
}
function set seed(s) {
init_genrand(s);
//return(seed);
}
function get seed() {
return(lastSeed);
}
function nextInt(n) {
return((genrand_int32() & 2147483647) % n);
}
function nextFloat() {
return(next(24) / 16777216);
}
function nextDouble() {
return(next(24) / 16777216);
}
function next(bits) {
if (bits < 32) {
return(genrand_int32() & ((1 << bits) - 1));
}
return(genrand_int32());
}
function init_genrand(s) {
s = int(s);
trace("Random::init_genrand(): seed=" + s);
var _local6 = getTimer();
lastSeed = s;
mta[0] = s;
var _local2 = s;
var _local3 = new src.util.Integer64();
var _local4 = N;
mti = 1;
while (mti < _local4) {
_local3.init32((_local2 >>> 30) ^ _local2);
_local3.mulu32(1812433253);
_local2 = (mta[mti] = int(_local3.lsb + mti));
mti++;
}
var _local7 = getTimer();
trace(("Random::init_genrand(): initialization ~" + (_local7 - _local6)) + "ms");
}
function genrand_int32() {
var _local9 = N;
var _local3 = 0;
if (mti >= _local9) {
if (mti == (_local9 + 1)) {
init_genrand(5489);
}
var _local8 = M;
var _local6 = UPPER_MASK;
var _local4 = LOWER_MASK;
var _local5 = mag01;
var _local11 = getTimer();
var _local2 = 0;
var _local7 = _local9 - _local8;
var _local10 = _local8 - _local9;
_local2 = 0;
while (_local2 < _local7) {
_local3 = (mta[_local2] & _local6) | (mta[_local2 + 1] & _local4);
mta[_local2] = (mta[_local2 + _local8] ^ (_local3 >>> 1)) ^ _local5[_local3 & 1];
_local2++;
}
_local7 = _local9 - 1;
while (_local2 < _local7) {
_local3 = (mta[_local2] & _local6) | (mta[_local2 + 1] & _local4);
mta[_local2] = (mta[_local2 + _local10] ^ (_local3 >>> 1)) ^ _local5[_local3 & 1];
_local2++;
}
_local3 = (mta[_local9 - 1] & _local6) | (mta[0] & _local4);
mta[_local9 - 1] = (mta[_local8 - 1] ^ (_local3 >>> 1)) ^ _local5[_local3 & 1];
mti = 0;
var _local12 = getTimer();
trace(((("Random::genrand_int32(): precalc " + _local9) + " new numbers ~") + (_local12 - _local11)) + "ms");
}
_local3 = mta[mti++];
_local3 = _local3 ^ (_local3 >>> 11);
_local3 = _local3 ^ ((_local3 << 7) & 2636928640);
_local3 = _local3 ^ ((_local3 << 15) & 4022730752);
_local3 = _local3 ^ (_local3 >>> 18);
return(_local3);
}
static var N = 624;
static var M = 397;
static var MATRIX_A = 2567483615;
static var UPPER_MASK = 2147483648;
static var LOWER_MASK = 2147483647;
static var mag01 = [0, 2567483615];
}
Symbol 376 MovieClip [__Packages.src.util.Integer64] Frame 0
class src.util.Integer64
{
var r, p, s;
function Integer64 (lowInt) {
r = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]];
p = [0, 0, 0, 0, 0];
s = [0, 0, 0];
if (lowInt != undefined) {
merge(lowInt);
}
}
function init(v) {
var _local2 = 0;
while (_local2 < p.length) {
p[_local2] = v.p[_local2];
_local2++;
}
}
function init32(n) {
p[0] = n & 32767;
n = n >>> 15;
p[1] = n & 32767;
n = n >>> 15;
p[2] = n & 3;
p[3] = 0;
p[4] = 0;
}
function get lsb() {
return((p[0] | (p[1] << SH)) | ((p[2] & 3) << 30));
}
function get msb() {
return((((p[2] >> 2) | ((p[3] << SH) >> 2)) | ((p[4] << (SH * 2)) >> 2)) & 2147483647);
}
function binaryShiftLeft(step) {
var _local2 = 0;
while (_local2 < step) {
shl();
_local2++;
}
}
function binaryShiftRight(step) {
var _local4 = (step / SH) >> 0;
var _local5 = step - (_local4 * SH);
var _local2 = p.length - 1;
while (_local2 > 0) {
var _local3 = 0;
while (_local3 < _local4) {
p[_local3] = p[_local3 + 1];
_local3++;
}
p[_local2--] = 0;
}
if (_local5 > 0) {
var _local3 = 0;
while (_local3 < _local5) {
shr();
_local3++;
}
}
}
function binaryNot(o) {
p[0] = p[0] ^ o.p[0];
p[1] = p[1] ^ o.p[1];
p[2] = p[2] ^ o.p[2];
p[3] = p[3] ^ o.p[3];
p[4] = p[4] ^ o.p[4];
}
function add64(o) {
var _local4 = 0;
var _local3 = 1;
var _local2 = 0;
while ((_local3 < p.length) && (o.p[_local2] != 0)) {
_local3++;
}
_local2 = 0;
while (_local2 < _local3) {
_local4 = _local4 + (p[_local2] + o.p[_local2]);
p[_local2] = _local4 & MASK;
_local4 = _local4 >> SH;
_local2++;
}
}
function add32(num) {
var _local2 = 0;
var _local5 = num & MASK;
num = num >> SH;
var _local6 = num & MASK;
num = num >> SH;
var _local4 = num & 3;
_local2 = _local2 + (p[0] + _local5);
p[0] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (p[1] + _local6);
p[1] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (p[2] + _local4);
p[2] = _local2 & MASK;
}
function mulu32(num) {
var _local3 = 0;
s[0] = num & MASK;
num = num >>> 15;
s[1] = num & MASK;
num = num >>> 15;
s[2] = num & 3;
var _local2 = 0;
while (_local2 < 3) {
var _local4 = s[_local2];
_local3 = _local4 * p[0];
r[_local2][0] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + (_local4 * p[1]);
r[_local2][1] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + (_local4 * p[2]);
r[_local2][2] = _local3 & 3;
_local2++;
}
_local3 = r[0][0];
p[0] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + (r[0][1] + r[1][0]);
p[1] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + ((r[0][2] + r[1][1]) + r[2][0]);
p[2] = _local3 & 3;
p[3] = 0;
p[4] = 0;
}
function mul64(o) {
var _local2 = 0;
var _local3 = 0;
while (_local3 < 5) {
var _local4 = o.p[_local3];
_local2 = _local4 * p[0];
r[_local3][0] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[1]);
r[_local3][1] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[2]);
r[_local3][2] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[3]);
r[_local3][3] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[4]);
r[_local3][4] = _local2 & MASK;
_local3++;
}
_local2 = r[0][0];
p[0] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (r[0][1] + r[1][0]);
p[1] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + ((r[0][2] + r[1][1]) + r[2][0]);
p[2] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (((r[0][3] + r[1][2]) + r[2][1]) + r[3][0]);
p[3] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + ((((r[0][4] + r[1][3]) + r[2][2]) + r[3][1]) + r[4][0]);
p[4] = _local2 & 7;
}
function mul32(value) {
mul64(new src.util.Integer64(value));
}
function merge(a) {
var _local2 = 0;
while (_local2 < 3) {
p[_local2] = p[_local2] + (a & 32767);
a = a >>> 15;
_local2++;
}
return(a);
}
function shl() {
var _local5 = 0;
var _local4 = 0;
var _local2 = 0;
var _local3 = p.length;
while (_local2 < _local3) {
_local5 = (p[_local2] & 16384) >> 14;
p[_local2] = p[_local2] << 1;
p[_local2] = (p[_local2] | _local4) & 32767;
_local2++;
_local4 = _local5;
}
}
function shr() {
var _local4 = 0;
var _local3 = 0;
var _local2 = p.length - 1;
while (_local2 >= 0) {
_local4 = (p[_local2] & 1) << 14;
p[_local2] = p[_local2] >> 1;
p[_local2] = (p[_local2] | _local3) & 32767;
_local2--;
_local3 = _local4;
}
}
static var MASK = 32767;
static var SH = 15;
}
Symbol 377 MovieClip [__Packages.com.king.farmmatch.Sounds] Frame 0
class com.king.farmmatch.Sounds
{
static var globalSound;
var soundMc, sound;
function Sounds (ownerMc, soundName) {
var _local2 = ownerMc.getNextHighestDepth();
soundMc = ownerMc.createEmptyMovieClip("soundMcc" + _local2, _local2);
sound = new Sound(soundMc);
sound.attachSound(soundName);
}
static function get(resourceName) {
var _local2 = soundMap[resourceName];
if ((_local2 == undefined) || (_local2 == null)) {
_local2 = new com.king.farmmatch.Sounds(_root, resourceName);
soundMap[resourceName] = _local2;
}
return(_local2);
}
static function toggleSound() {
if (globalSound == undefined) {
globalSound = new Sound(_root);
}
soundOn = !soundOn;
globalSound.setVolume((soundOn ? 100 : 0));
}
function setVolume(volume) {
sound.setVolume(volume);
}
function playLooping() {
sound.start(0, 9999999);
}
function stopAndPlayOffs(offs) {
sound.stop();
sound.start(offs, 0);
}
function stopAndPlay() {
sound.stop();
sound.start(0);
}
function playOffs(offs) {
sound.start(offs, 0);
}
function playOffsVolPan(offs, vol, pan) {
sound.start(offs, 0);
sound.setVolume(vol);
sound.setPan(pan);
}
function play() {
sound.start(0);
}
function stop() {
sound.stop();
}
static var soundMap = new Object();
static var soundOn = true;
}
Symbol 378 MovieClip [__Packages.com.king.farmmatch.Deck] Frame 0
class com.king.farmmatch.Deck
{
var random, size, deck;
function Deck (level, random) {
this.random = random;
var _local6 = TYPES[level];
var _local5 = COUNTS[level];
size = _local6 * _local5;
deck = new Array();
var _local3 = 0;
while (_local3 < _local6) {
var _local2 = 0;
while (_local2 < _local5) {
deck.push(_local3);
_local2++;
}
_local3++;
}
shuffle();
var _local4 = 0;
while (_local4 < (2 + level)) {
deck[_local4] = (-deck[_local4]) - 1;
_local4++;
}
deck.push(8);
size++;
shuffle();
}
function shuffle() {
var _local2 = 0;
while (_local2 < deck.length) {
var _local3 = random.nextInt(deck.length - _local2) + _local2;
var _local4 = deck[_local2];
deck[_local2] = deck[_local3];
deck[_local3] = _local4;
_local2++;
}
}
function pop() {
return(deck.pop());
}
static var TYPES = [6, 7, 8];
static var COUNTS = [6, 8, 10];
}
Symbol 379 MovieClip [__Packages.com.king.farmmatch.Tile] Frame 0
class com.king.farmmatch.Tile
{
var gameArea, dieOnLand, x, y, xTarget, yTarget, scale, scaleTarget, depth, multiplier, deathAnim, value, tileMc, shadowMc, flips, flipDuration, flipOffset, z, landed, hasShadows, flipTime, rotDir;
function Tile (gameArea, holderMc, x, y, depth, value) {
this.gameArea = gameArea;
dieOnLand = false;
this.x = x;
this.y = y;
xTarget = x;
yTarget = y;
scale = 29.3333333333333;
scaleTarget = 29.3333333333333;
this.depth = depth;
multiplier = 1;
deathAnim = 0;
if (value < 0) {
value = (-value) - 1;
multiplier = 2;
}
this.value = value;
tileMc = holderMc.attachMovie("TileHolder", "tile" + depth, depth);
showFace();
tileMc.tile.highlight._visible = false;
tileMc.tile.darkness._visible = false;
shadowMc = holderMc.attachMovie("TileShadow", "tileShadow" + depth, 1000 + depth);
shadowMc._alpha = 40;
var _local5 = new flash.filters.BlurFilter(8, 8, 2);
var _local4 = shadowMc.filters;
_local4.push(_local5);
shadowMc.filters = _local4;
land();
tileMc.tile.gotoAndStop(1);
}
function matches(tile) {
if (com.king.farmmatch.GameArea.DEBUG_MODE) {
return(true);
}
if (((value == 8) || (tile.value == 8)) && (value != tile.value)) {
return(true);
}
return(value == tile.value);
}
function firstFlyTo(xt, yt, delay, fast) {
xTarget = xt;
yTarget = yt;
tileMc.tile.gotoAndStop(1);
if (!fast) {
flips = 1.5;
flipDuration = 800;
flipOffset = 0.5;
} else {
flips = 0.5;
flipDuration = 400;
flipOffset = 0.5;
}
flip(delay);
}
function flyTo(xt, yt, delay) {
xTarget = xt;
yTarget = yt;
if (yt == y) {
flips = 0;
flipOffset = 0;
flipDuration = 300;
slide(delay);
} else {
flips = 1;
flipOffset = 0;
flipDuration = 400;
flip(delay);
}
}
function dieTo(xt, yt) {
dieOnLand = true;
xTarget = xt;
yTarget = yt;
flips = 0;
flipOffset = 0;
flipDuration = 150;
slide(0);
scaleTarget = 10;
tileMc.swapDepths(2000 + depth);
}
function land() {
x = xTarget;
y = yTarget;
z = 0;
scale = scaleTarget;
shadowMc._visible = false;
tileMc._x = x;
tileMc._y = y - z;
tileMc.tile.highlight._visible = false;
tileMc.tile.darkness._visible = false;
landed = true;
hasShadows = false;
tileMc.swapDepths(depth);
tileMc.tile._rotation = 0;
tileMc._rotation = 0;
tileMc._xscale = scale;
tileMc._yscale = scale;
showFace();
tileMc.onEnterFrame = undefined;
if (dieOnLand) {
if (deathAnim >= 0) {
var _local2 = 0;
while (_local2 < 5) {
var _local3 = tileMc._parent.attachMovie("Poof", "poof" + pp, 5000 + pp);
_local3.init(tileMc._x, tileMc._y, ((_local2 * Math.PI) * 2) / 5);
pp++;
_local2++;
}
if (deathAnim > 0) {
_local2 = 0;
while (_local2 < 8) {
var _local3 = tileMc._parent.attachMovie("Poof", "poof" + pp, 5000 + pp);
_local3.init(tileMc._x, tileMc._y, ((_local2 * Math.PI) * 2) / 8);
_local3.setTwirl(8);
pp++;
_local2++;
}
var _local3 = tileMc._parent.attachMovie("Poof", "poof" + pp, 5000 + pp);
_local3.init(tileMc._x, tileMc._y, 0);
_local3.setGravity(4 + int(deathAnim));
_local3.setSpeed(0.33);
pp++;
}
} else if (deathAnim == -1) {
var _local3 = tileMc._parent.attachMovie("Poof", "poof" + pp, 5000 + pp);
_local3.init(tileMc._x, tileMc._y, 0);
_local3.setGravity(9);
_local3.setSpeed(0.7);
pp++;
}
remove();
}
}
function slide(delay) {
if (!landed) {
return(undefined);
}
_global.animUntil = Math.max(_global.animUntil, getTimer() + delay);
flipTime = getTimer() + delay;
slideAnimate();
scaleTarget = 100;
landed = false;
tileMc.onEnterFrame = mx.utils.Delegate.create(this, slideAnimate);
}
function flip(delay) {
if (!landed) {
return(undefined);
}
_global.animUntil = Math.max(_global.animUntil, getTimer() + delay);
tileMc.swapDepths(2000 + depth);
rotDir = Math.atan2(yTarget - y, xTarget - x);
flipTime = getTimer() + delay;
flipAnimate();
scaleTarget = 100;
landed = false;
tileMc.onEnterFrame = mx.utils.Delegate.create(this, flipAnimate);
}
function showShadows() {
shadowMc._visible = true;
tileMc.tile.highlight._visible = true;
tileMc.tile.darkness._visible = true;
hasShadows = true;
}
function remove() {
tileMc.onEnterFrame = undefined;
tileMc.removeMovieClip();
shadowMc.removeMovieClip();
}
function flipAnimate() {
if (landed) {
return(undefined);
}
if (getTimer() < flipTime) {
return(undefined);
}
if (!hasMadeSound) {
gameArea.cardFlipped();
hasMadeSound = true;
}
if (!hasShadows) {
showShadows();
}
var _local2 = (getTimer() - flipTime) / flipDuration;
if (_local2 > 1) {
_local2 = 1;
land();
return(undefined);
}
var _local4 = (((_local2 * flips) + flipOffset) * Math.PI) * 2;
var _local7 = Math.abs(Math.sin(_local2 * Math.PI) * 32);
var _local3 = rotDir;
var _local11 = Math.cos(_local3) * Math.sin(_local4);
var _local10 = Math.sin(_local3) * Math.sin(_local4);
var _local12 = Math.cos(_local4);
var _local14 = 0.7071;
var _local15 = -0.7071;
var _local13 = 0;
var _local6 = ((_local11 * _local14) + (_local10 * _local15)) + (_local12 * _local13);
var _local9 = x + ((xTarget - x) * _local2);
var _local8 = y + ((yTarget - y) * _local2);
var _local5 = (scale + ((scaleTarget - scale) * _local2)) + (_local7 / 10);
shadowMc._x = _local9 - _local7;
shadowMc._y = _local8;
shadowMc.tile._rotation = ((-_local3) * 180) / Math.PI;
shadowMc._rotation = (_local3 * 180) / Math.PI;
shadowMc._xscale = Math.cos(_local4) * _local5;
shadowMc._yscale = _local5;
tileMc._x = _local9;
tileMc._y = _local8 - _local7;
tileMc.tile._rotation = ((-_local3) * 180) / Math.PI;
tileMc._rotation = (_local3 * 180) / Math.PI;
tileMc._xscale = Math.cos(_local4) * _local5;
tileMc._yscale = _local5;
if (tileMc._xscale < 0) {
tileMc.tile.highlight._alpha = (-_local6) * 80;
tileMc.tile.darkness._alpha = _local6 * 100;
tileMc.tile.gotoAndStop(1);
} else {
tileMc.tile.highlight._alpha = _local6 * 80;
tileMc.tile.darkness._alpha = (-_local6) * 100;
showFace();
}
}
function slideAnimate() {
if (landed) {
return(undefined);
}
if (getTimer() < flipTime) {
return(undefined);
}
var _local2 = (getTimer() - flipTime) / flipDuration;
if (_local2 > 1) {
_local2 = 1;
land();
return(undefined);
}
_local2 = 1 - ((Math.cos(_local2 * Math.PI) * 0.5) + 0.5);
var _local3 = scale + ((scaleTarget - scale) * _local2);
var _local5 = x + ((xTarget - x) * _local2);
var _local4 = y + ((yTarget - y) * _local2);
tileMc._xscale = _local3;
tileMc._yscale = _local3;
tileMc._x = _local5;
tileMc._y = _local4;
}
function setMood(mood) {
this.mood = mood;
tileMc.tile.face.gotoAndStop(mood);
}
function showFace() {
if (multiplier > 1) {
tileMc.tile.gotoAndStop(value + 11);
} else {
tileMc.tile.gotoAndStop(value + 2);
}
tileMc.tile.face.gotoAndStop(mood);
}
static var MOOD_HAPPY = 1;
static var MOOD_IDLE = 2;
static var MOOD_SAD = 3;
static var MOOD_SELECTED = 4;
var mood = MOOD_IDLE;
var hasMadeSound = false;
static var pp = 0;
}
Symbol 380 MovieClip [__Packages.src.util.TimeVerifier] Frame 0
class src.util.TimeVerifier
{
static var startClientTime, startGetTimer;
function TimeVerifier () {
}
static function checkTime() {
var _local2 = _root.clientTime;
if (_local2 == undefined) {
_local2 = 0;
}
var _local3 = getTimer();
if (!hasStarted) {
startClientTime = _local2;
startGetTimer = _local3;
hasStarted = true;
}
var _local4 = Math.abs(_local2 - startClientTime) - (_local3 - startGetTimer);
if ((_root.clientTime != undefined) && (_local4 > 10000)) {
if (hasWarned) {
fscommand ("playData", ("007 " + int(_local4)) + "=0");
hasWarned = true;
}
}
}
static var hasStarted = false;
static var hasWarned = false;
}
Symbol 381 MovieClip [__Packages.com.king.farmmatch.LevelTimer] Frame 0
class com.king.farmmatch.LevelTimer extends MovieClip
{
var head, mask;
function LevelTimer () {
super();
}
function setProgress(t) {
lastProgress = t;
head._y = (1 - t) * 264;
mask._y = ((1 - t) * 264) + 13;
}
function resetProgress(tt) {
var _local2 = lastProgress * (1 - tt);
head._y = (1 - _local2) * 264;
mask._y = ((1 - _local2) * 264) + 13;
}
function warn() {
head.gotoAndStop(2);
}
function lose() {
head.gotoAndStop(3);
}
function init() {
head.gotoAndStop(1);
}
var lastProgress = 0;
}
Symbol 382 MovieClip [__Packages.com.king.farmmatch.Background] Frame 0
class com.king.farmmatch.Background extends MovieClip
{
var cloud0, cloud1, cloud2, cloud3, cloud4, cloud5, cloud6, cloud7, page, gotoAndStop;
function Background () {
super();
}
function onEnterFrame() {
updateCloud(cloud0, 0);
updateCloud(cloud1, 1);
updateCloud(cloud2, 2);
updateCloud(cloud3, 3);
updateCloud(cloud4, 4);
updateCloud(cloud5, 5);
updateCloud(cloud6, 6);
updateCloud(cloud7, 7);
}
function updateCloud(cloud, offs) {
cloud.gotoAndStop((((page - 1) * 4) + 1) + (offs & 3));
var _local6 = 1455;
var _local4 = (((getTimer() * 10) + (offs * 1.4764762)) / 1000) + ((offs * _local6) / 8);
var _local8 = (((getTimer() * 14) - (offs * 1.4764762)) / 15042) + (((offs * Math.PI) * 2) / 8);
_local4 = _local4 - (int(_local4 / _local6) * _local6);
var _local7 = ((Math.sin(_local8 * 0.1) * 0.3) + 1.3) * 100;
var _local3 = cloud._xscale / _local7;
if (_local3 < 1) {
_local3 = 1 / _local3;
}
if (_local3 > 1.05) {
cloud._xscale = _local7;
cloud._yscale = 10000 / cloud._xscale;
}
if (int(cloud._x) != int(_local4 - 200)) {
cloud._x = _local4 - 200;
}
}
function setPage(page) {
this.page = page;
gotoAndStop(page);
}
}
Symbol 383 MovieClip [__Packages.com.king.farmmatch.Tear] Frame 0
class com.king.farmmatch.Tear extends MovieClip
{
var startTime, startX, startY, xa, ya, _rotation, _x, _y, _alpha, _xscale, removeMovieClip;
function Tear () {
super();
}
function init(d) {
var _local2 = Math.sin(d);
var _local3 = Math.cos(d);
startTime = getTimer();
startX = (_local2 * 10) + (((Math.random() * 2) - 1) * 4);
startY = (_local3 * 10) + (((Math.random() * 2) - 1) * 4);
xa = _local2 + (((Math.random() * 2) - 1) * 0.5);
ya = _local3 + (((Math.random() * 2) - 1) * 0.5);
_rotation = ((Math.atan2(ya, xa) * 180) / Math.PI) - 90;
onEnterFrame();
}
function onEnterFrame() {
var _local2 = (getTimer() - startTime) / 500;
_x = startX + ((xa * _local2) * 30);
_y = (startY + ((ya * _local2) * 30)) + ((_local2 * _local2) * 10);
_alpha = 100 - (_local2 * 100);
if ((_alpha <= 0) || (_xscale <= 0)) {
removeMovieClip();
}
}
}