Frame 1
function goFromPreloaderToNext() {
_root.play();
}
Stage.showMenu = false;
stop();
var previousTime = null;
var waitTime = 3000;
var CPMStarPoolID = 1052;
var CPMStarSubPoolID = 12;
System.security.allowDomain("server.cpmstar.com");
adBox.loadMovie((("http://server.cpmstar.com/adviewas2.swf?poolid=" + CPMStarPoolID) + "&subpoolid=") + CPMStarSubPoolID);
Frame 2
function toggleSound() {
soundOn = !soundOn;
optionBtns.sndBtn.gotoAndStop(soundOn + 1);
_root.bgMusic.setVolume(100 * soundOn);
_root.buttonSound.start(0, 1);
}
function saveGame() {
myLSO = SharedObject.getLocal("enDice");
if (myLSO.data.myObj == undefined) {
}
myObj = {};
myObj.objArray = new Array();
myObj.objArray[0] = (levelsDecimal = convertFromBinToDec(levelsStr));
myObj.objArray[1] = soundOn;
myLSO.data.myObj = myObj;
myLSO.data.flush();
}
function loadGame() {
myLSO = SharedObject.getLocal("enDice");
if (myLSO.data.myObj == undefined) {
return(false);
}
levelsDecimal = myLSO.data.myObj.objArray[0];
levelsStr = convertFromDecToBin(levelsDecimal);
soundOn = myLSO.data.myObj.objArray[1];
return(true);
}
function convertFromDecToBin(td) {
var _local2 = "";
var _local3 = td;
var _local1 = 35;
while (_local1 >= 0) {
if (Math.pow(2, _local1) <= _local3) {
_local3 = _local3 - Math.pow(2, _local1);
_local2 = _local2 + "1";
} else {
_local2 = _local2 + "0";
}
_local1--;
}
return(_local2);
}
function convertFromBinToDec(b) {
var _local3 = 0;
var _local1 = 0;
while (_local1 < b.length) {
if (b.charAt((b.length - 1) - _local1) == "1") {
_local3 = _local3 + Math.pow(2, _local1);
}
_local1++;
}
return(_local3);
}
var levelsDecimal = 0;
var levelsStr = "";
var i = 0;
while (i < 35) {
levelsStr = levelsStr + "0";
i++;
}
var soundOn = true;
var levelSelected = 0;
var optionBtns = _root.attachMovie("OptionButtons", "OptionButtons1", 9000);
optionBtns._x = 0;
optionBtns._y = 0;
optionBtns.gotoAndStop(1);
optionBtns.sndBtn.gotoAndStop(soundOn + 1);
optionBtns._visible = false;
var menuMusic = new Sound();
menuMusic.attachSound("MENUMUSIC");
var bgMusic = new Sound();
bgMusic.attachSound("BGMUSIC");
var moveSound = new Sound();
moveSound.attachSound("MOVESOUND");
var zoneSound = new Sound();
zoneSound.attachSound("ZONESOUND");
var winSound = new Sound();
winSound.attachSound("WINSOUND");
var buttonSound = new Sound();
buttonSound.attachSound("BUTTONSOUND");
loadGame();
_root.bgMusic.setVolume(100 * soundOn);
menuMusic.start(0, 1000);
Frame 3
function toMenu() {
_root.optionBtns.menuBtn._visible = false;
_root.menuBox.gotoAndStop(1);
}
function gotoLevelSelect() {
_root.buttonSound.start(0, 1);
_root.optionBtns.menuBtn._visible = true;
_root.menuBox.gotoAndStop(2);
var _local2 = 1;
while (_local2 <= _root.levelsStr.length) {
_root.menuBox["l" + _local2].num.gotoAndStop(_local2);
_root.menuBox["l" + _local2]._alpha = 50;
_root.menuBox["l" + _local2].btn.enabled = false;
_root.menuBox["l" + _local2].star._visible = false;
if (((_local2 == 1) || (_local2 == 11)) || (_local2 == 21)) {
_root.menuBox["l" + _local2]._alpha = 100;
_root.menuBox["l" + _local2].btn.enabled = true;
if (_root.levelsStr.charAt(_root.levelsStr.length - _local2) == "1") {
_root.menuBox["l" + _local2].star._visible = true;
}
} else if (_root.levelsStr.charAt((_root.levelsStr.length - _local2) + 1) == "1") {
_root.menuBox["l" + _local2]._alpha = 100;
_root.menuBox["l" + _local2].btn.enabled = true;
if (_root.levelsStr.charAt(_root.levelsStr.length - _local2) == "1") {
_root.menuBox["l" + _local2].star._visible = true;
}
}
_local2++;
}
}
function destroyAtMenu() {
clearInterval(bgAnimation);
bgDice.swapDepths(_root.menuBox);
bgDice.removeMovieClip();
bgDice = null;
xSpeed = (ySpeed = (speed = null));
}
function gotoCredits() {
_root.buttonSound.start(0, 1);
_root.optionBtns.menuBtn._visible = true;
_root.menuBox.gotoAndStop(3);
}
function findZone() {
return(int(Math.random() * 4));
}
function moveIntoZone(z) {
if (z == 0) {
bgDice._x = -bgDice._width;
bgDice._y = (Math.random() * (Stage.height + bgDice._height)) - bgDice._height;
} else if (z == 1) {
bgDice._x = (Math.random() * (Stage.width + bgDice._width)) - bgDice._width;
bgDice._y = -bgDice._height;
} else if (z == 2) {
bgDice._x = Stage.width;
bgDice._y = (Math.random() * (Stage.height + bgDice._height)) - bgDice._height;
} else if (z == 3) {
bgDice._x = (Math.random() * (Stage.width + bgDice._width)) - bgDice._width;
bgDice._y = Stage.height;
}
}
function leaveZone() {
var _local1 = Stage.width / 2;
var _local4 = _local1 - (bgDice._x + (bgDice._width / 2));
var _local3 = _local1 - (bgDice._y + (bgDice._height / 2));
var _local2 = Math.atan2(_local3, _local4);
xSpeed = Math.cos(_local2) * speed;
ySpeed = Math.sin(_local2) * speed;
}
function bgMain() {
if (((((bgDice._x + xSpeed) < (-bgDice._width)) || ((bgDice._x + xSpeed) > Stage.width)) || ((bgDice._y + ySpeed) < (-bgDice._height))) || ((bgDice._y + ySpeed) > Stage.height)) {
moveIntoZone(findZone());
leaveZone();
var _local1;
do {
_local1 = int(Math.random() * bgDice._totalframes) + 1;
} while (_local1 == bgDice._currentframe);
bgDice.gotoAndStop(_local1);
}
bgDice._x = bgDice._x + xSpeed;
bgDice._y = bgDice._y + ySpeed;
}
function onMouseDown() {
if (_root.menuBox._currentframe == 2) {
var _local2 = 1;
while (_local2 <= 35) {
if ((_root.menuBox["l" + _local2]._alpha == 100) && (_root.menuBox["l" + _local2].hitTest(_root._xmouse, _root._ymouse))) {
levelSelected = _local2 - 1;
destroyAtMenu();
_root.buttonSound.start(0, 1);
menuMusic.stop();
bgMusic.start(0, 1000);
_root.optionBtns.menuBtn._visible = true;
gotoAndStop ("gameFrame");
break;
}
_local2++;
}
}
}
stop();
_root.optionBtns.gotoAndStop(1);
_root.optionBtns._visible = true;
_root.optionBtns.sndBtn.gotoAndStop(_root.soundOn + 1);
_root.optionBtns.menuBtn._visible = false;
var bgDice = _root.attachMovie("BGDice", "BD", 1);
bgDice._alpha = 30;
bgDice._xscale = (bgDice._yscale = 280);
bgDice._x = Math.random() * 480;
bgDice._y = Math.random() * 480;
bgDice.gotoAndStop(int(Math.random() * bgDice._totalframes) + 1);
var xSpeed = 1;
var ySpeed = 1;
var speed = 1;
bgDice.swapDepths(_root.menuBox);
moveIntoZone(findZone());
leaveZone();
bgAnimation = setInterval(bgMain, 10);
Frame 4
function toMenu() {
clearInterval(mainInterval);
KEY_U_Down = (KEY_U_Reset = (KEY_R_Down = (KEY_R_Reset = (KEY_SPACE_Down = null))));
LAYER_Home = (LAYER_Die = null);
board.destroy();
board = null;
transitionAnimator.destroy();
transitionAnimator = null;
bgMusic.stop();
menuMusic.start(0, 1000);
gotoAndStop ("menuFrame");
}
function toWin() {
clearInterval(mainInterval);
KEY_U_Down = (KEY_U_Reset = (KEY_R_Down = (KEY_R_Reset = (KEY_SPACE_Down = null))));
LAYER_Home = (LAYER_Die = null);
board.destroy();
board = null;
transitionAnimator.destroy();
transitionAnimator = null;
bgMusic.stop();
menuMusic.start(0, 1000);
gotoAndStop ("winFrame");
}
function main() {
while ((previousTime + nextCycleTime) > getTimer()) {
}
previousTime = getTimer();
if (board.clip._x > 0) {
transitionAnimator.slideIn();
} else if (board.clip._x <= (-Stage.width)) {
if ((levelSelected + 1) <= 35) {
if (levelSelected < 9) {
_root.levelNumTxt.gotoAndStop(levelSelected + 1);
} else {
_root.levelNumTxt.gotoAndStop(levelSelected + 1);
}
board.load(Levels["level" + (levelSelected + 1)]);
transitionAnimator.setUpForSlideIn();
_root.winSound.start(0, 1);
_root.helpTxt.gotoAndStop(levelSelected + 1);
} else {
_root.saveGame();
toWin();
}
} else if (board.clip._x < 0) {
transitionAnimator.slideOut();
} else {
checkKeys();
board.animate();
if (!board.animating) {
if (board.isSolved()) {
transitionAnimator.setUpForSlideOut();
transitionAnimator.slideOut();
_root.winSound.start(0, 1);
var _local3 = "";
var _local2 = 0;
while (_local2 < _root.levelsStr.length) {
if (((_root.levelsStr.length - 1) - _local2) == levelSelected) {
_local3 = _local3 + "1";
} else {
_local3 = _local3 + _root.levelsStr.charAt(_local2);
}
_local2++;
}
_root.levelsStr = _local3;
levelSelected++;
_root.saveGame();
}
if (KEY_U_Down) {
if (KEY_U_Reset) {
board.undo();
KEY_U_Reset = false;
}
}
if (KEY_R_Down) {
if (KEY_R_Reset) {
board.restart();
KEY_R_Reset = false;
}
}
if (KEY_M_Down) {
if (KEY_M_Reset) {
toMenu();
_root.buttonSound.start(0, 1);
KEY_M_Reset = false;
}
}
if (KEY_S_Down) {
if (KEY_S_Reset) {
_root.toggleSound();
KEY_S_Reset = false;
}
}
if (KEY_SPACE_Down) {
board.hideDie();
} else {
board.showDie();
}
_root.solvedTxt.text = board.isSolved();
}
}
}
function onMouseMove() {
board.mouseMove(board.clip._xmouse, board.clip._ymouse);
}
function onMouseDown() {
board.mouseDown(board.clip._xmouse, board.clip._ymouse);
}
function onMouseUp() {
board.mouseUp(board.clip._xmouse, board.clip._ymouse);
}
function checkKeys() {
KEY_U_Down = Key.isDown(85);
KEY_R_Down = Key.isDown(82);
KEY_M_Down = Key.isDown(77);
KEY_S_Down = Key.isDown(83);
KEY_SPACE_Down = Key.isDown(32);
if (!KEY_U_Down) {
KEY_U_Reset = true;
}
if (!KEY_R_Down) {
KEY_R_Reset = true;
}
if (!KEY_M_Down) {
KEY_M_Reset = true;
}
if (!KEY_S_Down) {
KEY_S_Reset = true;
}
}
stop();
var fps = 60;
var nextCycleTime = int(1000 / fps);
var previousTime = getTimer();
var KEY_U_Down = false;
var KEY_U_Reset = true;
var KEY_R_Down = false;
var KEY_R_Reset = true;
var KEY_M_Down = false;
var KEY_M_Reset = true;
var KEY_S_Down = false;
var KEY_S_Reset = true;
var KEY_SPACE_Down = false;
var LAYER_Home = 1000;
var LAYER_Die = 2000;
var board = new Board(8, 8, 480, 480);
var transitionAnimator = new SlideTransition(board.clip);
_root.optionBtns.gotoAndStop(2);
board.load(Levels["level" + (levelSelected + 1)]);
if (levelSelected < 9) {
_root.levelNumTxt.gotoAndStop(levelSelected + 1);
} else {
_root.levelNumTxt.gotoAndStop(levelSelected + 1);
}
_root.helpTxt.gotoAndStop(levelSelected + 1);
transitionAnimator.setUpForSlideIn();
_root.winSound.start(0, 1);
mainInterval = setInterval(main, 9);
Frame 5
stop();
_root.optionBtns.gotoAndStop(1);
Symbol 9 MovieClip [Outline] Frame 1
stop();
Symbol 23 MovieClip [Square] Frame 1
stop();
Symbol 31 Button
on (press) {
_root.editor.changeSelected(this);
}
Symbol 35 Button
on (press) {
_root.editor.changeSelected(this);
}
Symbol 38 Button
on (press) {
_root.editor.changeSelected(this);
}
Symbol 43 Button
on (press) {
_root.editor.changeSelected(this);
}
Symbol 46 Button
on (press) {
_root.editor.changeSelected(this);
}
Symbol 49 Button
on (press) {
_root.editor.changeSelected(this);
}
Symbol 54 Button
on (press) {
_root.editor.save();
}
Symbol 56 Button
on (press) {
_root.editor.load();
}
Symbol 59 Button
on (press) {
_root.editor.toggleScale();
}
Symbol 61 Button
on (press) {
_root.editor.toggleScale();
}
Symbol 62 MovieClip Frame 1
stop();
Symbol 63 MovieClip [Editor] Frame 1
stop();
Symbol 66 Button
on (press) {
_root.toggleSound();
}
Symbol 69 MovieClip Frame 1
stop();
Symbol 72 Button
on (press) {
_root.toMenu();
_root.buttonSound.start(0, 1);
}
Symbol 75 Button
on (press) {
_root.board.restart();
_root.buttonSound.start(0, 1);
}
Symbol 78 Button
on (press) {
_root.board.undo();
_root.buttonSound.start(0, 1);
}
Symbol 81 Button
on (press) {
_root.editor.hide();
_root.buttonSound.start(0, 1);
}
Symbol 84 Button
on (press) {
_root.editor.show();
_root.buttonSound.start(0, 1);
}
Symbol 85 MovieClip Frame 1
stop();
Symbol 86 MovieClip [OptionButtons] Frame 1
stop();
Symbol 92 MovieClip [BGDice] Frame 1
stop();
Symbol 105 MovieClip Frame 1
stop();
Symbol 109 Button
on (press) {
_root.goFromPreloaderToNext();
_root.buttonSound.start(0, 1);
}
Symbol 111 MovieClip [___FirstToLoad] Frame 1
_root.stop();
var PercentLoaded = ((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
var PercentTime = (((getTimer() - _root.previousTime) / _root.waitTime) * 100);
if (_root.loadingBar._visible) {
if (_root.previousTime == null) {
_root.previousTime = getTimer();
die.bar._yscale = 0;
} else if (PercentTime > PercentLoaded) {
if (PercentLoaded != 100) {
die.gotoAndStop(Math.floor((PercentLoaded / 100) * (die._totalframes - 1)) + 1);
die.bar._yscale = PercentLoaded;
} else {
die.bar._yscale = 100;
die.gotoAndStop(die._totalframes);
gotoAndStop ("Loaded");
}
} else if (PercentTime < PercentLoaded) {
if (PercentTime < 100) {
die.gotoAndStop(Math.floor((PercentTime / 100) * (die._totalframes - 1)) + 1);
die.bar._yscale = PercentTime;
} else {
die.bar._yscale = 100;
die.gotoAndStop(die._totalframes);
gotoAndStop ("Loaded");
}
}
}
Symbol 111 MovieClip [___FirstToLoad] Frame 2
gotoAndPlay (1);
Symbol 111 MovieClip [___FirstToLoad] Frame 3
stop();
Symbol 115 Button
on (press) {
getURL ("http://armorgames.com", "_blank");
}
Symbol 244 MovieClip [__Packages.Levels] Frame 0
class Levels
{
function Levels () {
}
static var level1 = "sd1,9,486,0,135,297,189,297,1,0,351,243,243,243,2,0,297,135,297,297,3,";
static var level2 = "sd1,9,486,0,243,189,189,189,1,0,189,297,243,297,2,0,297,297,297,189,3,";
static var level3 = "sd1,8,480,0,150,270,210,270,1,0,150,210,270,270,2,";
static var level4 = "sd1,9,486,0,297,243,189,243,1,0,243,189,243,297,2,";
static var level5 = "sd1,8,480,0,210,150,210,330,1,0,270,270,210,270,3,0,270,330,270,210,4,0,210,210,270,150,2,";
static var level6 = "sd1,9,486,0,243,297,189,297,3,0,189,189,243,189,2,0,297,189,297,297,2,";
static var level7 = "sd1,8,480,0,210,330,210,270,1,0,270,150,270,210,3,0,330,270,270,270,2,0,150,210,210,210,4,";
static var level8 = "sd1,9,486,0,243,135,189,135,2,0,243,189,297,135,2,0,135,243,189,243,1,0,351,243,243,243,1,0,243,297,297,243,3,";
static var level9 = "sd1,9,486,0,189,297,243,297,2,0,297,297,243,243,2,0,297,243,189,189,2,0,189,243,297,189,2,";
static var level10 = "sd1,9,486,0,351,243,297,189,1,0,135,243,189,189,1,0,135,351,243,297,3,0,351,351,297,297,3,0,135,135,189,243,3,0,243,135,243,189,1,0,351,135,297,243,3,0,243,351,189,297,1,";
static var level11 = "sd1,8,480,0,150,270,210,270,1,0,90,270,210,150,2,0,390,270,270,150,2,0,330,270,270,270,1,0,150,210,210,210,1,0,330,210,270,210,1,";
static var level12 = "sd1,9,486,0,243,243,243,243,3,0,297,297,189,297,3,0,297,189,189,189,3,";
static var level13 = "sd1,8,480,0,150,150,210,150,1,0,150,210,270,150,2,0,150,270,210,90,3,0,330,270,270,90,1,0,330,210,210,330,2,0,330,150,270,330,3,";
static var level14 = "sd1,8,480,0,270,270,270,210,3,0,210,270,330,270,2,0,150,210,270,330,2,0,210,150,210,330,3,0,270,150,210,210,2,0,330,210,150,270,3,";
static var level15 = "sd1,9,486,0,243,189,189,243,2,0,243,135,243,243,3,0,243,297,135,243,2,0,243,243,297,243,1,0,243,351,351,243,3,";
static var level16 = "sd1,8,480,0,150,150,210,150,2,0,150,270,270,330,1,0,210,330,330,270,2,0,330,330,150,210,3,0,330,210,150,330,2,0,270,150,330,150,1,";
static var level17 = "sd1,9,486,0,351,243,189,189,2,0,243,351,243,189,2,0,135,189,189,243,1,0,297,297,297,243,3,0,189,135,243,297,1,";
static var level18 = "sd1,9,486,0,297,189,189,351,1,0,243,81,189,297,1,0,297,297,243,297,1,0,189,81,243,243,2,0,189,135,297,243,1,0,189,243,243,189,1,0,297,351,189,189,2,0,243,351,243,135,1,0,135,243,297,135,1,0,351,189,297,81,1,";
static var level19 = "sd1,9,486,0,189,189,243,189,1,0,297,189,243,297,1,0,351,243,189,243,2,0,135,243,243,243,2,0,243,135,297,243,2,";
static var level20 = "sd1,8,480,0,270,210,210,210,3,0,150,330,150,270,3,0,210,390,210,330,2,0,330,150,330,210,3,0,330,270,330,330,1,0,150,210,150,150,1,0,270,90,270,150,2,0,210,150,210,90,1,0,90,270,90,210,2,0,390,210,390,270,2,0,270,330,270,390,1,0,210,270,270,270,3,";
static var level21 = "sd1,9,486,0,135,297,135,297,1,0,189,243,189,351,2,0,297,243,243,351,1,0,351,297,297,351,1,0,189,135,351,297,1,0,297,135,189,135,2,0,243,243,189,189,2,0,135,135,297,189,1,0,351,135,297,135,2,";
static var level22 = "sd1,9,486,0,135,135,189,135,2,0,297,189,351,189,4,0,189,189,135,189,4,0,189,297,135,297,4,0,135,351,189,351,2,0,351,351,297,351,2,0,297,297,351,297,4,0,135,243,189,243,6,0,351,243,297,243,6,0,243,135,243,189,6,0,243,351,243,297,6,0,351,135,297,135,2,";
static var level23 = "sd1,8,480,0,150,270,150,90,2,0,330,330,150,210,2,0,330,210,210,150,3,0,150,150,210,270,3,0,210,90,270,210,2,0,210,210,270,330,1,0,270,270,330,270,4,0,270,390,330,390,3,";
static var level24 = "sd1,8,480,0,150,270,210,270,3,0,150,330,90,330,4,0,270,150,270,210,3,0,330,210,390,150,3,0,210,150,210,210,2,0,150,210,90,150,2,0,330,330,390,330,1,0,270,330,330,390,2,0,210,330,150,390,3,0,150,150,150,90,1,0,330,150,330,90,4,0,330,270,270,270,2,";
static var level25 = "sd1,9,486,0,243,243,243,189,1,0,243,135,189,297,1,0,297,135,189,351,2,0,297,189,135,297,3,0,297,243,135,243,2,0,351,243,243,243,2,0,351,297,189,243,3,0,297,351,135,189,1,0,243,297,189,135,1,0,351,189,243,351,2,";
static var level26 = "sd1,9,486,0,135,189,135,297,2,0,135,135,189,297,3,0,189,135,189,351,2,0,189,189,135,351,2,0,351,297,297,135,3,0,351,243,297,81,2,0,297,297,351,81,2,0,297,243,351,135,2,";
static var level27 = "sd1,9,486,0,243,297,135,297,1,0,243,243,135,243,3,0,189,189,189,189,2,0,135,243,243,243,2,0,135,297,243,297,1,0,297,189,297,189,2,0,351,243,351,243,2,0,351,297,351,297,1,";
static var level28 = "sd1,8,480,0,150,210,150,150,2,0,210,210,150,210,3,0,150,270,150,330,1,0,210,270,150,270,2,0,210,330,210,330,1,0,270,270,270,330,3,0,270,330,330,330,2,0,330,270,330,270,2,0,270,210,330,210,2,0,330,210,330,150,1,0,270,150,270,150,1,0,210,150,210,150,2,";
static var level29 = "sd1,9,486,0,135,135,189,351,2,0,243,135,135,297,1,0,351,135,135,189,4,0,135,243,189,135,1,0,243,243,243,243,3,0,351,243,297,351,1,0,135,351,351,297,4,0,243,351,351,189,1,0,351,351,297,135,2,";
static var level30 = "sd1,8,480,0,270,210,150,270,1,0,270,150,210,270,2,0,330,270,150,330,1,0,330,90,330,330,4,0,330,210,210,330,2,0,270,90,270,270,3,0,210,150,150,210,1,0,150,90,150,150,1,0,330,150,270,330,3,0,210,90,210,210,2,";
static var level31 = "sd1,9,486,0,189,243,189,135,2,0,189,297,297,189,3,0,243,297,297,135,2,0,297,297,189,189,3,0,297,243,243,135,2,0,243,189,243,243,1,";
static var level32 = "sd1,9,486,0,351,351,243,351,2,0,189,189,297,297,3,0,297,243,189,243,5,0,135,297,351,189,4,0,243,135,135,135,1,";
static var level33 = "sd1,8,480,0,150,150,210,270,4,0,330,210,270,210,3,0,210,270,330,150,2,0,270,330,150,330,1,";
static var level34 = "sd1,9,486,0,135,243,81,189,3,0,189,189,135,243,2,0,243,243,189,297,4,0,297,297,243,243,2,0,351,243,297,189,3,0,405,189,351,243,1,0,81,297,405,297,1,";
static var level35 = "sd1,9,486,0,243,243,189,189,1,0,189,189,189,243,3,0,243,81,243,243,2,0,297,189,243,189,3,0,405,243,297,189,1,0,297,297,297,243,4,0,243,405,297,297,2,0,189,297,243,297,4,0,81,243,189,297,1,";
}
Symbol 245 MovieClip [__Packages.SlideTransition] Frame 0
class SlideTransition
{
var clip, speed, animating;
function SlideTransition (mc) {
clip = mc;
speed = 10;
animating = false;
}
function destroy() {
clip.removeMovieClip();
clip = null;
speed = null;
animating = null;
}
function setUpForSlideIn() {
clip._x = Stage.width;
}
function slideIn() {
if ((clip._x - speed) > 0) {
clip._x = clip._x - speed;
} else {
clip._x = 0;
}
}
function setUpForSlideOut() {
clip._x = 0;
}
function slideOut() {
if ((clip._x - speed) > (-Stage.width)) {
clip._x = clip._x - speed;
} else {
clip._x = -Stage.width;
}
}
}
Symbol 246 MovieClip [__Packages.Board] Frame 0
class Board
{
var clip, rows, cols, width, height, dieWidth, dieHeight, selectedDie, dies, animating, animation, dieSpeed, homes, undoList, pathShower;
function Board (numRows, numCols, stageWidth, stageHeight) {
clip = _root.createEmptyMovieClip("clip", 10);
rows = numRows;
cols = numCols;
width = stageWidth;
height = stageHeight;
dieWidth = width / cols;
dieHeight = height / rows;
selectedDie = null;
dies = new Array();
animating = false;
animation = new Array();
dieSpeed = dieWidth / 15;
homes = new Array();
undoList = new Array();
pathShower = new PathShower();
}
function isOnHome(d) {
var _local2 = 0;
while (_local2 < homes.length) {
if ((d.clip._x == homes[_local2].clip._x) && (d.clip._y == homes[_local2].clip._y)) {
return(true);
}
_local2++;
}
return(false);
}
function destroy() {
clip.removeMovieClip();
clip = null;
rows = (cols = (width = (height = (dieWidth = (dieHeight = null)))));
selectedDie = null;
while (dies.length > 0) {
dies[dies.length - 1].destroy();
dies[dies.length - 1] = null;
dies.pop();
}
dies = null;
animating = null;
while (animation.length > 0) {
animation.pop();
}
dieSpeed = null;
while (homes.length > 0) {
homes[homes.length - 1].destroy();
homes[homes.length - 1] = null;
homes.pop();
}
homes = null;
clearUndoList();
undoList = null;
pathShower.destroy();
pathShower = null;
}
function hideDie() {
if (dies[0].clip._alpha == 100) {
var _local2 = 0;
while (_local2 < dies.length) {
dies[_local2].clip._alpha = 50;
_local2++;
}
}
}
function showDie() {
if (dies[0].clip._alpha < 100) {
var _local2 = 0;
while (_local2 < dies.length) {
dies[_local2].clip._alpha = 100;
_local2++;
}
}
}
function clearUndoList() {
var _local4 = 0;
while (_local4 < undoList.length) {
var _local2 = 0;
while (_local2 < undoList[_local4].length) {
var _local3 = 0;
while (_local3 < undoList[_local4][_local2].length) {
undoList[_local4][_local2][_local3] = null;
_local3++;
}
undoList[_local4][_local2] = null;
_local2++;
}
undoList[_local4] = null;
_local4++;
}
undoList = null;
undoList = new Array();
}
function undo() {
if (undoList.length > 0) {
var _local4 = undoList[undoList.length - 1];
var _local2 = 0;
while (_local2 < _local4.length) {
dies[_local2].changeMainProperties(_local4[_local2][0], _local4[_local2][1], _local4[_local2][2]);
var _local3 = 0;
while (_local3 < _local4[_local2].length) {
_local4[_local2][_local3] = null;
_local3++;
}
_local2++;
}
_local4 = null;
undoList.pop();
}
pathShower.hide();
}
function addUndoMarker() {
undoList.push(new Array());
var _local3 = undoList[undoList.length - 1];
var _local2 = 0;
while (_local2 < dies.length) {
_local3.push(new Array(dies[_local2].clip._x, dies[_local2].clip._y, dies[_local2].movesLeft));
_local2++;
}
}
function typeToNum(d) {
if (d.type == "BLACK") {
return(0);
}
if (d.type == "RED") {
return(1);
}
return(2);
}
function save() {
var _local3 = ((("sd1," + rows) + ",") + width) + ",";
var _local2 = 0;
while (_local2 < dies.length) {
_local3 = _local3 + (((((((((((typeToNum(dies[_local2]) + ",") + dies[_local2].startingX) + ",") + dies[_local2].startingY) + ",") + homes[_local2].clip._x) + ",") + homes[_local2].clip._y) + ",") + dies[_local2].startingNumOfMoves) + ",");
_local2++;
}
return(_local3);
}
function load(str) {
if (Number(str.substr(0, 2)) > 0) {
load(Levels["level" + Number(str.substr(0, 2))]);
return(undefined);
}
clearUndoList();
while (dies.length > 0) {
dies[dies.length - 1].destroy();
dies[dies.length - 1] = null;
dies.pop();
}
while (homes.length > 0) {
homes[homes.length - 1].destroy();
homes[homes.length - 1] = null;
homes.pop();
}
var _local6 = 0;
var _local2 = 0;
var _local5 = 0;
var _local3 = 0;
while (_local3 < str.length) {
if (str.charAt(_local3) == ",") {
if (_local6 == 0) {
} else if (_local6 == 1) {
rows = (cols = Number(str.substr(_local2, _local3 - _local2)));
if (rows == 8) {
dieSpeed = dieWidth / 13;
} else if (rows == 9) {
dieSpeed = dieWidth / 15;
}
} else if (_local6 == 2) {
width = (height = Number(str.substr(_local2, _local3 - _local2)));
dieWidth = (dieHeight = width / cols);
} else {
if (_local5 == 0) {
var _local7 = Number(str.substr(_local2, _local3 - _local2));
if (_local7 == 1) {
addDie(1, 1, "RED");
} else if (_local7 == 2) {
addDie(1, 1, "BLUE");
} else {
addDie(1, 1, "BLACK");
}
} else if (_local5 == 1) {
dies[dies.length - 1].clip._x = (dies[dies.length - 1].desX = (dies[dies.length - 1].startingX = Number(str.substr(_local2, _local3 - _local2))));
} else if (_local5 == 2) {
dies[dies.length - 1].clip._y = (dies[dies.length - 1].desY = (dies[dies.length - 1].startingY = Number(str.substr(_local2, _local3 - _local2))));
} else if (_local5 == 3) {
addHome(1, 1);
homes[homes.length - 1].clip._x = Number(str.substr(_local2, _local3 - _local2));
} else if (_local5 == 4) {
homes[homes.length - 1].clip._y = Number(str.substr(_local2, _local3 - _local2));
} else if (_local5 == 5) {
dies[dies.length - 1].startingNumOfMoves = (dies[dies.length - 1].movesLeft = Number(str.substr(_local2, _local3 - _local2)));
dies[dies.length - 1].clip.gotoAndStop(dies[dies.length - 1].movesLeft + 1);
}
_local5++;
if (_local5 >= 6) {
_local5 = 0;
}
}
_local2 = _local3 + 1;
_local6++;
}
_local3++;
}
restart();
}
function isSolved() {
var _local6 = 0;
var _local5 = false;
var _local4 = 0;
while (_local4 < homes.length) {
_local5 = false;
var _local3 = 0;
while (_local3 < dies.length) {
if ((dies[_local3].clip._x == homes[_local4].clip._x) && (dies[_local3].clip._y == homes[_local4].clip._y)) {
if (dies[_local3].movesLeft == 0) {
_local6++;
}
_local5 = true;
if (homes[_local4].clip._currentframe == 1) {
_root.zoneSound.start(0, 1);
}
homes[_local4].clip.gotoAndStop(2);
break;
}
_local3++;
}
if (!_local5) {
homes[_local4].clip.gotoAndStop(1);
}
_local4++;
}
return(_local6 == homes.length);
}
function restart() {
var _local2 = 0;
while (_local2 < dies.length) {
dies[_local2].resetToStart();
_local2++;
}
clearUndoList();
pathShower.hide();
var _local3 = 0;
while (_local3 < homes.length) {
homes[_local3].clip.gotoAndStop(1);
_local2 = 0;
while (_local2 < dies.length) {
if ((dies[_local2].clip._x == homes[_local3].clip._x) && (dies[_local2].clip._y == homes[_local3].clip._y)) {
homes[_local3].clip.gotoAndStop(2);
break;
}
_local2++;
}
_local3++;
}
}
function checkForCollisions(p, d) {
var _local6;
var _local5;
var _local2 = 0;
while (_local2 < dies.length) {
if (p != dies[_local2]) {
_local6 = dieWidth - Math.abs(dies[_local2].clip._x - p.clip._x);
_local5 = dieHeight - Math.abs(dies[_local2].clip._y - p.clip._y);
if ((_local5 == dieHeight) && (_local6 > 0.5)) {
if (d == "R") {
dies[_local2].desX = (dies[_local2].clip._x = p.clip._x + dieWidth);
} else if (d == "L") {
dies[_local2].desX = (dies[_local2].clip._x = p.clip._x - dieWidth);
}
checkForCollisions(dies[_local2], d);
} else if ((_local6 == dieWidth) && (_local5 > 0.5)) {
if (d == "D") {
dies[_local2].desY = (dies[_local2].clip._y = p.clip._y + dieHeight);
} else if (d == "U") {
dies[_local2].desY = (dies[_local2].clip._y = p.clip._y - dieHeight);
}
checkForCollisions(dies[_local2], d);
}
}
_local2++;
}
}
function fitIntoPlace() {
var _local2 = 0;
while (_local2 < dies.length) {
dies[_local2].clip._x = (Math.floor(dies[_local2].clip._x / dieWidth) * dieWidth) + (dieWidth / 2);
dies[_local2].clip._y = (Math.floor(dies[_local2].clip._y / dieHeight) * dieHeight) + (dieHeight / 2);
_local2++;
}
}
function animate() {
animating = animation.length > 0;
if (animating) {
var _local5 = dieSpeed;
var _local3 = "";
var _local2 = 0;
while (_local2 < animation.length) {
if (_local2 == 0) {
var _local4 = Math.sqrt(((animation[_local2].desX - animation[_local2].clip._x) * (animation[_local2].desX - animation[_local2].clip._x)) + ((animation[_local2].desY - animation[_local2].clip._y) * (animation[_local2].desY - animation[_local2].clip._y)));
if (_local4 < _local5) {
_local5 = _local4;
}
if (animation[_local2].clip._x < animation[_local2].desX) {
_local3 = "R";
} else if (animation[_local2].clip._x > animation[_local2].desX) {
_local3 = "L";
}
if (animation[_local2].clip._y < animation[_local2].desY) {
_local3 = "D";
} else if (animation[_local2].clip._y > animation[_local2].desY) {
_local3 = "U";
}
}
animation[_local2].moveToDestination(_local5);
if ((selectedDie.type == "BLACK") || (selectedDie.type == "BLUE")) {
checkForCollisions(animation[_local2], _local3);
}
if (animation[_local2].isAtDestination()) {
pathShower.hide();
if (animation[_local2] == selectedDie) {
selectedDie = null;
}
animation.splice(_local2, 1);
_local2--;
fitIntoPlace();
}
_local2++;
}
}
}
function mouseMove(x, y) {
if (selectedDie != null) {
if ((((x > 0) && (x < width)) && (y > 0)) && (y < height)) {
if (animating) {
} else if (selectedDie.movesLeft > 0) {
var _local3;
var _local2;
var _local5 = x - selectedDie.clip._x;
var _local4 = y - selectedDie.clip._y;
if ((Math.abs(_local5) >= (dieWidth / 2)) || (Math.abs(_local4) >= (dieHeight / 2))) {
if (Math.abs(_local5) > Math.abs(_local4)) {
if (_local5 < 0) {
_local3 = selectedDie.clip._x - dieWidth;
} else {
_local3 = selectedDie.clip._x + dieWidth;
}
_local2 = selectedDie.clip._y;
} else {
if (_local4 < 0) {
_local2 = selectedDie.clip._y - dieHeight;
} else {
_local2 = selectedDie.clip._y + dieHeight;
}
_local3 = selectedDie.clip._x;
}
if ((!selectedDie.hitTest(x, y)) && (dieCanMoveTo(selectedDie, _local3, _local2))) {
pathShower.show(selectedDie, _local3, _local2);
} else {
pathShower.hide();
}
} else {
pathShower.hide();
}
}
} else {
pathShower.hide();
}
}
}
function mouseDown(x, y) {
if ((((x > 0) && (x < width)) && (y > 0)) && (y < height)) {
if (animating) {
} else {
selectedDie = null;
var _local2 = 0;
while (_local2 < dies.length) {
if (dies[_local2].hitTest(x, y)) {
if ((selectedDie == null) || (dies[_local2].clip.getDepth() > selectedDie.clip.getDepth())) {
if (dies[_local2].movesLeft > 0) {
selectedDie = dies[_local2];
}
}
}
_local2++;
}
}
}
}
function mouseUp(x, y) {
if ((((x > 0) && (x < width)) && (y > 0)) && (y < height)) {
if (animating) {
} else if (selectedDie != null) {
var _local4;
var _local3;
var _local6 = x - selectedDie.clip._x;
var _local5 = y - selectedDie.clip._y;
if ((Math.abs(_local6) >= (dieWidth / 2)) || (Math.abs(_local5) >= (dieHeight / 2))) {
if (Math.abs(_local6) > Math.abs(_local5)) {
if (_local6 < 0) {
_local4 = selectedDie.clip._x - dieWidth;
} else {
_local4 = selectedDie.clip._x + dieWidth;
}
_local3 = selectedDie.clip._y;
} else {
if (_local5 < 0) {
_local3 = selectedDie.clip._y - dieHeight;
} else {
_local3 = selectedDie.clip._y + dieHeight;
}
_local4 = selectedDie.clip._x;
}
if ((!selectedDie.hitTest(x, y)) && (dieCanMoveTo(selectedDie, _local4, _local3))) {
selectedDie.moveTo(_local4, _local3);
}
if ((selectedDie.desX != selectedDie.clip._x) || (selectedDie.desY != selectedDie.clip._y)) {
addUndoMarker();
animation.push(selectedDie);
_root.moveSound.start(0, 1);
} else {
selectedDie = null;
}
} else {
selectedDie = null;
}
}
}
}
function dieCanMoveTo(p, x, y) {
if (selectedDie.type == "BLACK") {
return(blackDieCanMoveTo(p, x, y));
}
if (selectedDie.type == "RED") {
return(redDieCanMoveTo(p, x, y));
}
if (selectedDie.type == "BLUE") {
return(blueDieCanMoveTo(p, x, y));
}
}
function blackDieCanMoveTo(p, x, y) {
var _local6 = x - p.clip._x;
var _local5 = y - p.clip._y;
if (((((_local6 == _local5) || (x < 0)) || (x > width)) || (y < 0)) || (y > height)) {
return(false);
}
var _local2 = 0;
while (_local2 < dies.length) {
if (dies[_local2].hitTest(x, y)) {
if (dies[_local2].type == "BLUE") {
return(false);
}
return(blackDieCanMoveTo(dies[_local2], x + _local6, y + _local5));
}
_local2++;
}
return(true);
}
function redDieCanMoveTo(p, x, y) {
var _local3 = x - p.clip._x;
var _local2 = y - p.clip._y;
if (((((_local3 == _local2) || (x < 0)) || (x > width)) || (y < 0)) || (y > height)) {
return(false);
}
return(true);
}
function blueDieCanMoveTo(p, x, y) {
var _local6 = x - p.clip._x;
var _local5 = y - p.clip._y;
if (((((_local6 == _local5) || (x < 0)) || (x > width)) || (y < 0)) || (y > height)) {
return(false);
}
var _local2 = 0;
while (_local2 < dies.length) {
if (dies[_local2].hitTest(x, y)) {
if (dies[_local2].type == "BLUE") {
return(false);
}
return(blueDieCanMoveTo(dies[_local2], x + _local6, y + _local5));
}
_local2++;
}
return(true);
}
function addDie(x, y, c) {
dies.push(new Die((Math.floor(x / dieWidth) * dieWidth) + (dieWidth / 2), (Math.floor(y / dieHeight) * dieHeight) + (dieHeight / 2), dieWidth, dieHeight, 0, c, clip));
}
function addHome(x, y) {
homes.push(new Home((Math.floor(x / dieWidth) * dieWidth) + (dieWidth / 2), (Math.floor(y / dieHeight) * dieHeight) + (dieHeight / 2), dieWidth, dieHeight, clip));
}
}
Symbol 247 MovieClip [__Packages.Die] Frame 0
class Die
{
var clip, type, clr, clrStr, startingNumOfMoves, movesLeft, startingX, desX, startingY, desY, sound;
function Die (x, y, width, height, numOfMoves, typeOfDie, c) {
clip = c.attachMovie("Square", "Square" + _root.LAYER_Die, _root.LAYER_Die);
_root.LAYER_Die++;
clip._x = x;
clip._y = y;
clip._width = width;
clip._height = height;
clip.gotoAndStop(numOfMoves + 1);
type = typeOfDie;
clr = new Color(clip.BG);
if (type == "BLACK") {
clrStr = Number(2236962);
} else if (type == "RED") {
clrStr = Number(6693410);
} else if (type == "BLUE") {
clrStr = Number(2237030);
}
clr.setRGB(clrStr);
clip.filters = [new flash.filters.DropShadowFilter(1)];
startingNumOfMoves = (movesLeft = numOfMoves);
startingX = (desX = x);
startingY = (desY = y);
sound = new Sound();
}
function changeMainProperties(x, y, numMoves) {
clip._x = (desX = x);
clip._y = (desY = y);
movesLeft = numMoves;
clip.gotoAndStop(movesLeft + 1);
clr.setRGB(clrStr);
}
function resetToStart() {
desX = (clip._x = startingX);
desY = (clip._y = startingY);
movesLeft = startingNumOfMoves;
clip.gotoAndStop(movesLeft + 1);
clr.setRGB(clrStr);
}
function destroy() {
clip.removeMovieClip();
clip = null;
startingNumOfMoves = (movesLeft = null);
startingX = (desX = null);
startingY = (desY = null);
}
function isAtDestination() {
return((clip._x == desX) && (clip._y == desY));
}
function moveToDestination(speed) {
if (movesLeft > 0) {
if (clip._x < desX) {
clip._x = clip._x + speed;
} else if (clip._x > desX) {
clip._x = clip._x - speed;
}
if (clip._y < desY) {
clip._y = clip._y + speed;
} else if (clip._y > desY) {
clip._y = clip._y - speed;
}
if (isAtDestination()) {
movesLeft--;
clip.gotoAndStop(movesLeft + 1);
clr.setRGB(clrStr);
}
}
}
function moveTo(x, y) {
if (((((movesLeft > 0) && (x > 0)) && (x < _root.board.width)) && (y > 0)) && (y < _root.board.height)) {
if (x < clip._x) {
x = clip._x - clip._width;
} else if (x > clip._x) {
x = clip._x + clip._width;
}
if (y < clip._y) {
y = clip._y - clip._height;
} else if (y > clip._y) {
y = clip._y + clip._height;
}
desX = x;
desY = y;
}
}
function hitTest(x, y) {
return(clip.hitTest(x, y));
}
}
Symbol 248 MovieClip [__Packages.PathShower] Frame 0
class PathShower
{
var clip, clr, clrStr;
function PathShower () {
clip = _root.attachMovie("PathShower", "PathShower" + _root.LAYER_Piece, _root.LAYER_Piece);
_root.LAYER_Piece++;
clr = new Color(clip.piece.BG);
clrStr = Number(2236962);
clr.setRGB(clrStr);
clip._alpha = 30;
clip._visible = false;
}
function destroy() {
clip.removeMovieClip();
clip = null;
clr = null;
clrStr = null;
}
function show(p, x, y) {
clip._x = p.clip._x;
clip._y = p.clip._y;
clip._xscale = p.clip._xscale;
clip._yscale = p.clip._yscale;
var _local4 = x - p.clip._x;
var _local3 = y - p.clip._y;
if (_local4 > 0) {
clip._rotation = 0;
} else if (_local4 < 0) {
clip._rotation = 180;
} else if (_local3 > 0) {
clip._rotation = 90;
} else if (_local3 < 0) {
clip._rotation = 270;
}
clr.setRGB(clrStr);
clip._visible = true;
}
function hide() {
clip._visible = false;
}
}
Symbol 249 MovieClip [__Packages.Home] Frame 0
class Home
{
var clip, startingX, startingY;
function Home (x, y, width, height, c) {
clip = c.attachMovie("Outline", "Outline" + _root.LAYER_Home, _root.LAYER_Home);
_root.LAYER_Home++;
clip._x = x;
clip._y = y;
clip._xscale = width;
clip._yscale = height;
startingX = x;
startingY = y;
}
function destroy() {
clip.removeMovieClip();
clip = null;
}
function hitTest(x, y) {
return(clip.hitTest(x, y));
}
}
Symbol 132 Button
on (press) {
getURL ("http://www.armorgames.com", "_blank");
}
Symbol 135 MovieClip Frame 1
_root.stop();
gotoAndPlay (2);
Symbol 135 MovieClip Frame 157
_root.nextFrame();
Symbol 139 Button
on (press) {
getURL ("http://armorgames.com", "_blank");
}
Symbol 140 Button
on (press) {
getURL ("http://armorblog.com", "_blank");
}
Symbol 143 Button
on (press) {
_root.gotoLevelSelect();
}
Symbol 144 Button
on (press) {
_root.gotoCredits();
}
Symbol 184 MovieClip Frame 1
stop();
Symbol 191 Button
on (press) {
getURL ("http://smad.newgrounds.com/", "_blank");
}
Symbol 192 Button
on (press) {
getURL ("http://armorgames.com/user/soapaintnice", "_blank");
}
Symbol 193 Button
on (press) {
getURL ("http://zadamanim.newgrounds.com/", "_blank");
}
Symbol 194 Button
on (press) {
getURL ("http://armorgames.com/", "_blank");
}
Symbol 195 MovieClip Frame 1
stop();
Symbol 206 MovieClip Frame 1
stop();
Symbol 242 MovieClip Frame 1
stop();