Frame 1
function checkPercent() {
percent = (getBytesLoaded() / getBytesTotal()) * 100;
if (loader.fill._y > ((-percent) / 2)) {
loader.fill._y--;
} else if (percent == 100) {
clearInterval(update);
loader.play();
}
}
stop();
_root.attachMovie("loader", "loader", 1);
loader._x = (Stage.width / 2) - (loader._width / 2);
loader._y = Stage.height / 2;
startY = loader._y - 10;
update = setInterval(checkPercent, 10);
onEnterFrame = function () {
if (loader._y < loader.targetY) {
dy = loader._y - startY;
loader._y = loader._y + (dy * 0.2);
}
if (loader._y > loader.targetY) {
gotoAndStop ("menu");
}
};
Frame 2
function init() {
music_sound = new Sound();
music_sound.attachSound("music");
light_sound = new Sound();
light_sound.attachSound("light_sound");
if ((_global.music == undefined) || (_global.music == "off")) {
music_sound.start(0, 9999999);
_global.music = "on";
}
music_sound.setVolume(35);
saveFile = SharedObject.getLocal("Lights_Out_3D");
generateBackground();
game = {active:false, tileW:50, currentLayer:2, currentTile:null, currentMap:1, currentScore:0, totalScore:0, Mode:"makeCustom", totalMoves:0, overallMoves:0};
loadGame();
saveGame();
}
function generateBackground() {
d = 0;
xp = 10;
yp = 10;
_root.attachMovie("empty", "backgroundTiles", 1);
y = 0;
while (y < 4) {
x = 0;
while (x < 4) {
name = (("t_" + y) + "_") + x;
backgroundTiles.attachMovie("menuTile", name, d);
d++;
backgroundTiles[name]._x = xp;
backgroundTiles[name]._y = yp;
backgroundTiles[name].gotoAndStop("off");
xp = xp + 110;
x++;
}
yp = yp + 110;
xp = 10;
y++;
}
backgroundTiles._alpha = 15;
i = 0;
while (i < 4) {
y = Math.floor(Math.random() * 7);
x = Math.floor(Math.random() * 9);
changeLights(x, y);
i++;
}
wait = setInterval(triggerLights, 1000);
generateMenu();
}
function triggerLights() {
y = Math.floor(Math.random() * 4);
x = Math.floor(Math.random() * 4);
changeLights(x, y);
}
function changeLights(x, y) {
tile1 = backgroundTiles[(("t_" + y) + "_") + x];
tile2 = backgroundTiles[(("t_" + (y + 1)) + "_") + x];
tile3 = backgroundTiles[(("t_" + (y - 1)) + "_") + x];
tile4 = backgroundTiles[(("t_" + y) + "_") + (x + 1)];
tile5 = backgroundTiles[(("t_" + y) + "_") + (x - 1)];
i = 1;
while (i <= 5) {
tile = _root["tile" + i];
if (tile != undefined) {
frame = tile._currentframe;
if (frame == 1) {
tile.gotoAndStop("on");
} else {
tile.gotoAndStop("off");
}
}
i++;
}
}
function generateMenu() {
buttons = ["New Game", "Continue", "Random", "Play Custom", "Make Custom", "How To Play", "Highscores", "Credits"];
_root.attachMovie("empty", "menuClips", 2);
menuClips.attachMovie("tittle", "tittle", 200);
menuClips.tittle._x = Stage.width / 2;
menuClips.tittle._y = (menuClips.tittle._height / 2) + 50;
i = 0;
while (i < buttons.length) {
name = buttons[i];
menuClips.attachMovie("menuButton", name, i);
menuClips[name]._x = Stage.width / 2;
menuClips[name]._y = (i * 30) + 200;
menuClips[name].t.text = buttons[i];
i++;
}
_root.attachMovie("error_message", "errorMessage", 3);
errorMessage._x = Stage.width / 2;
errorMessage._y = Stage.height - 20;
}
function saveGame() {
saveFile.data.currentMap = game.currentMap;
saveFile.data.totalScore = game.totalScore;
}
function loadGame() {
errorMessage.display_txt.text = "*Looking for saved game*";
if (saveFile.data.currentMap != undefined) {
errorMessage.display_txt.text = "*Loading saved game*";
game.currentMap = saveFile.data.currentMap;
game.totalScore = saveFile.data.totalScore;
i = 0;
while (i < 5) {
errorMessage.display_txt.text = "*Looking for custom map data*";
if (saveFile.data["customMapName" + i] != undefined) {
_root["customMap" + i] = new Object();
_root["customMap" + i].name = saveFile.data["customMapName" + i];
_root["customMap" + i].map = saveFile.data["customMapArray" + i];
errorMessage.display_txt.text = ("*Loading Custom Map : " + _root["customMap" + i].name) + "*";
errorMessage.play();
}
i++;
}
errorMessage.display_txt.text = "*Game data loaded successfully*";
menuClips.NewGame.toString.text = "Continue";
loaded = true;
errorMessage.play();
menuClips._y = 0;
} else {
errorMessage.display_txt.text = "*No saved game found*";
errorMessage.play();
menuClips._y = 0;
}
}
function setupBoard(quitButton, infoPannel, resetButton, lvl) {
if (quitButton != undefined) {
_root.attachMovie("menuButton", "Quit", 200);
Quit.t.text = "Quit";
Quit._x = (Quit._width / 2) + 10;
Quit._y = (Quit._height / 2) + 10;
}
if (resetButton != undefined) {
_root.attachMovie("menuButton", "Reset", 201);
Reset.t.text = "Reset Level";
Reset._x = (Reset._width / 2) + 10;
Reset._y = (Reset._height / 2) + 35;
}
if (infoPannel != undefined) {
_root.attachMovie("info", "info", 202);
info._x = Stage.width - 10;
info._y = 10;
if (game.Mode == "normal") {
info.lvl.text = game.currentMap;
info.score.text = game.totalScore;
info.moves.text = game.totalMoves;
} else {
info.lvl.text = lvl;
info.score.text = "n/a";
info.moves.text = game.totalMoves;
}
}
}
function loadScores() {
var _local6 = "http://localhost/gameTest2/lightOut_highscores.php?task=read";
var _local5 = new LoadVars();
_local5.onLoad = function (success) {
if (success) {
scoreArray = this.scores;
scoreArray = scoreArray.split("|");
var _local2 = new Array();
i = 0;
while (i < (scoreArray.length - 1)) {
_local2.push({user:scoreArray[i], score:scoreArray[i + 1]});
i = i + 2;
}
_local2.sort(compareNumbers);
i = 0;
while (i < _local2.length) {
i++;
}
displayScores(_local2);
}
};
_local5.load(_local6);
}
function compareNumbers(a, b) {
res = (Number(a.score) > Number(b.score)) - (Number(a.score) < Number(b.score));
return(res);
}
function displayScores(scores) {
p = 1;
i = scores.length - 1;
while (p < 6) {
scores_page["name" + p].text = scores[i].user;
scores_page["score" + p].text = scores[i].score;
p++;
i--;
}
}
stop();
loaded = false;
init();
menuClips["New Game"].btn.onRelease = function () {
removeMovieClip(menuClips);
game.currentMap = 1;
game.currentScore = 0;
game.totalScore = 0;
game.totalMoves = 0;
game.Mode = "normal";
gotoAndStop ("game");
setupBoard(1, 1, 1);
};
menuClips.Continue.btn.onRelease = function () {
removeMovieClip(menuClips);
game.Mode = "normal";
setupBoard(1, 1, 1);
gotoAndStop ("game");
};
menuClips.Random.btn.onRelease = function () {
removeMovieClip(menuClips);
setupBoard(1, 1, 1);
game.Mode = "random";
gotoAndStop ("game");
};
menuClips["How To Play"].btn.onRelease = function () {
menuClips._y = 500;
attachMovie("help_page", "help_page", 4);
help_page._x = Stage.width / 2;
help_page._y = Stage.height / 2;
help_page.btn.onRelease = function () {
removeMovieClip(help_page);
menuClips._y = 0;
};
};
menuClips.Highscores.btn.onRelease = function () {
menuClips._y = 500;
attachMovie("scores_page", "scores_page", 4);
scores_page._x = Stage.width / 2;
scores_page._y = Stage.height / 2;
loadScores();
scores_page.btn.onRelease = function () {
removeMovieClip(scores_page);
menuClips._y = 0;
};
};
menuClips.Credits.btn.onRelease = function () {
menuClips._y = 500;
attachMovie("credits_page", "credits_page", 4);
credits_page._x = Stage.width / 2;
credits_page._y = Stage.height / 2;
credits_page.btn.onRelease = function () {
removeMovieClip(credits_page);
menuClips._y = 0;
};
};
menuClips["Play Custom"].btn.onRelease = function () {
menuClips._y = 500;
_root.attachMovie("empty", "customs", 5);
i = 1;
while (i < 7) {
if (i != 6) {
name = _root["customMap" + i].name;
customs.attachMovie("menuButton", "loadCustom" + i, i);
customs["loadCustom" + i]._x = Stage.width / 2;
customs["loadCustom" + i]._y = (i * 40) + 160;
customs["loadCustom" + i].t.text = name;
} else {
customs.attachMovie("menuButton", "Back", i);
customs.Back.t.text = "Back";
customs.Back._x = Stage.width / 2;
customs.Back._y = (i * 40) + 160;
}
i++;
}
customs.Back.btn.onRelease = function () {
removeMovieClip(customs);
menuClips._y = 0;
};
customs.loadCustom1.btn.onRelease = function () {
if (customMap1.name != undefined) {
removeMovieClip(customs);
removeMovieClip(menuClips);
game.currentMap = customMap1.map;
game.Mode = "playCustom";
gotoAndStop ("game");
setupBoard(1, 1, 1, customMap1.name);
}
};
customs.loadCustom2.btn.onRelease = function () {
if (customMap2.name != undefined) {
removeMovieClip(customs);
removeMovieClip(menuClips);
game.currentMap = customMap2.map;
game.Mode = "playCustom";
gotoAndStop ("game");
setupBoard(1, 1, 1, customMap2.name);
}
};
customs.loadCustom3.btn.onRelease = function () {
if (customMap3.name != undefined) {
removeMovieClip(customs);
removeMovieClip(menuClips);
game.currentMap = customMap3.map;
game.Mode = "playCustom";
gotoAndStop ("game");
setupBoard(1, 1, 1, customMap3.name);
}
};
customs.loadCustom4.btn.onRelease = function () {
if (customMap4.name != undefined) {
removeMovieClip(customs);
removeMovieClip(menuClips);
game.currentMap = customMap4.map;
game.Mode = "playCustom";
gotoAndStop ("game");
setupBoard(1, 1, 1, customMap4.name);
}
};
customs.loadCustom5.btn.onRelease = function () {
if (customMap5.name != undefined) {
removeMovieClip(customs);
removeMovieClip(menuClips);
game.currentMap = customMap5.map;
game.Mode = "playCustom";
gotoAndStop ("game");
setupBoard(1, 1, 1, customMap5.name);
}
};
};
menuClips["Make Custom"].btn.onRelease = function () {
setupBoard(1);
game.Mode = "makeCustom";
_root.attachMovie("menuButton", "saveCustom", 10);
saveCustom.t.text = "Save Level";
saveCustom._x = Stage.width / 2;
saveCustom._y = Stage.height - 60;
removeMovieClip(menuClips);
gotoAndStop ("game");
};
Frame 3
function buildCube(cubeToBuild) {
layersY = [];
_root.attachMovie("empty", "cube", 1);
layer = 0;
while (layer < cubeToBuild.length) {
cube.attachMovie("empty", "layer_" + layer, layer);
layerWidth = cubeToBuild[layer].length;
layerHeight = cubeToBuild[layer][0].length;
game.clip = cube["layer_" + layer];
game.clip._y = ((-layer) * game.tileW) - (400 + (layer * 2500));
layersY.push((-layer) * game.tileW);
x = 0;
while (x < layerWidth) {
y = 0;
while (y < layerWidth) {
name = (("t_" + x) + "_") + y;
frame = cubeToBuild[layer][x][y];
depth = (((((y + x) * game.tileW) / 2) * 300) + ((y - x) * game.tileW)) + 1;
game.clip.attachMovie("tile", name, depth);
game.clip[name]._x = (y - x) * game.tileW;
game.clip[name]._y = ((y + x) * game.tileW) / 2;
game.clip[name].gotoAndStop(frame);
game.clip[name].select.gotoAndStop("off");
y++;
}
x++;
}
layer++;
}
cube._x = Stage.width / 2;
cube._y = Stage.height / 2;
game.active = true;
}
function detectKeys() {
if (Key.isDown(17)) {
game.currentLayer = 0;
moveLayers();
} else if (Key.isDown(16)) {
game.currentLayer = 1;
moveLayers();
} else {
game.currentLayer = 2;
}
}
function makeMove() {
x = Number(substring(game.currentTile, 24, 1));
y = Number(substring(game.currentTile, 26, 1));
l = Number(substring(game.currentTile, 20, 1));
if (game.Mode == "makeCustom") {
tile = cube["layer_" + l][(("t_" + x) + "_") + y];
frame = tile._currentframe;
if (frame == 1) {
tile.gotoAndStop("on");
} else {
tile.gotoAndStop("off");
}
} else {
if (game.Mode != "random") {
light_sound.start();
}
tile1 = cube["layer_" + l][(("t_" + x) + "_") + y];
tile2 = cube["layer_" + l][(("t_" + (x + 1)) + "_") + y];
tile3 = cube["layer_" + l][(("t_" + (x - 1)) + "_") + y];
tile4 = cube["layer_" + l][(("t_" + x) + "_") + (y + 1)];
tile5 = cube["layer_" + l][(("t_" + x) + "_") + (y - 1)];
tile6 = cube["layer_" + (l + 1)][(("t_" + x) + "_") + y];
tile7 = cube["layer_" + (l - 1)][(("t_" + x) + "_") + y];
i = 1;
while (i <= 7) {
tile = _root["tile" + i];
if (tile != undefined) {
frame = tile._currentframe;
if (frame == 1) {
tile.gotoAndStop("on");
} else {
tile.gotoAndStop("off");
}
}
i++;
}
if (game.Mode != "random") {
game.totalMoves++;
info.moves.text = game.totalMoves;
}
if (checkForWin() && (game.Mode != "random")) {
Quit._y = Quit._y - 100;
Reset._y = Reset._y - 100;
info._y = info._y - 100;
removeMovieClip(cube);
_root.attachMovie("win_page", "winPage", 1000);
winPage._x = Stage.width / 2;
winPage._y = Stage.height / 2;
game.currentScore = 300;
if (game.Mode == "normal") {
winPage.gotoAndStop(1);
winPage.score.text = game.currentScore;
winPage.moves.text = game.totalMoves;
winPage.total.text = game.totalScore;
pauseT = 50;
scoreTicker = setInterval(calcScore, 10);
} else if (game.Mode == "playCustom") {
winPage.gotoAndStop(2);
winPage.moves.text = game.totalMoves;
winPage.btn.onRelease = function () {
Quit.btn.onRelease();
};
} else if (game.Mode == "playRandom") {
winPage.gotoAndStop(2);
winPage.moves.text = game.totalMoves;
winPage.btn.onRelease = function () {
Quit.btn.onRelease();
};
}
}
}
}
function calcScore() {
game.overallMoves = game.overallMoves + game.totalMoves;
if (pauseT > 0) {
pauseT--;
} else {
if (game.currentScore > 0) {
game.currentScore--;
game.totalScore++;
winPage.score.text = game.currentScore;
winPage.total.text = game.totalScore;
} else if (game.totalMoves > 0) {
game.totalMoves--;
game.totalScore = game.totalScore - 5;
winPage.moves.text = game.totalMoves;
winPage.total.text = game.totalScore;
}
winPage.btn.onRelease = function () {
game.totalScore = game.totalScore + game.currentScore;
game.totalMoves = 0;
game.currentScore = 0;
info.moves.text = game.totalMoves;
clearInterval(scoreTicker);
game.currentMap++;
if (_root["cubeMap" + game.currentMap] != undefined) {
Quit._y = Quit._y + 100;
Reset._y = Reset._y + 100;
info._y = info._y + 100;
saveFile.data.currentMap = game.currentMap;
saveFile.data.totalScore = game.totalScore;
saveFile.flush();
buildCube(_root["cubeMap" + game.currentMap]);
removeMovieClip(winPage);
info.lvl.text = game.currentMap;
info.score.text = game.totalScore;
} else {
winPage.gotoAndStop(3);
winPage.score.text = game.totalScore;
winPage.moves.text = game.overallMoves;
winPage.go_btn.onRelease = function () {
removeMovieClip(cube);
removeMovieClip(winPage);
removeMovieClip(Quit);
_root.gotoAndStop("menu");
};
winPage.submit_btn.onRelease = function () {
sendScore();
winPage.go_btn.onRelease();
};
}
};
}
}
function checkForWin() {
if ((game.Mode == "normal") || (game.Mode == "playRandom")) {
l = 0;
while (l < _root["cubeMap" + game.currentMap].length) {
x = 0;
while (x < layerWidth) {
y = 0;
while (y < layerWidth) {
name = (("t_" + x) + "_") + y;
tile = cube["layer_" + l][(("t_" + x) + "_") + y];
if (tile._currentframe == 2) {
return(false);
}
y++;
}
x++;
}
l++;
}
return(true);
}
l = 0;
while (l < game.currentMap.length) {
x = 0;
while (x < layerWidth) {
y = 0;
while (y < layerWidth) {
name = (("t_" + x) + "_") + y;
tile = cube["layer_" + l][(("t_" + x) + "_") + y];
if (tile._currentframe == 2) {
return(false);
}
y++;
}
x++;
}
l++;
}
return(true);
}
function getCustomMap() {
tempMap = [];
tempLayer = [];
l = 0;
while (l < 3) {
x = 0;
while (x < 3) {
tempColl = [];
y = 0;
while (y < 3) {
tile = cube["layer_" + l][(("t_" + x) + "_") + y];
tempColl.push(tile._currentframe);
y++;
}
tempLayer.push(tempColl);
x++;
}
tempRow = [];
tempMap.push(tempLayer);
tempLayer = [];
l++;
}
return(tempMap);
}
function saveCustomMap(mapNumber, mapName) {
errorMessage.display_txt.text = "*Scanning current map*";
mapArray = getCustomMap();
errorMessage.display_txt.text = "*saving out map data...*";
_root["customMap" + mapNumber] = new Object();
_root["customMap" + mapNumber].name = mapName;
_root["customMap" + mapNumber].map = mapArray;
saveFile.data["customMapName" + mapNumber] = name;
saveFile.data["customMapArray" + mapNumber] = _root["customMap" + mapNumber].map;
errorMessage.display_txt.text = "*Map Data saved successfully*";
errorMessage.play();
saveFile.data["customMapName" + mapNumber] = mapName;
saveFile.data["customMapArray" + mapNumber] = _root["customMap" + mapNumber].map;
saveFile.flush();
savePage.cancel_btn.onRelease();
}
function sendScore() {
var _local3 = (("http://localhost/gameTest2/lightOut_highscores.php?task=submit&user=" + winPage.user.text) + "&score=") + game.totalScore;
var _local2 = new LoadVars();
_local2.onLoad = function (success) {
if (success) {
removeMovieClip(cube);
removeMovieClip(winPage);
removeMovieClip(Quit);
_root.gotoAndStop("menu");
} else {
errorMessage.display_txt.text = "*Error occured when sending score*";
errorMessage.play();
}
};
}
function randomMoves() {
moveTotal = Math.ceil(Math.random() * 10) + 6;
m = 0;
while (m < moveTotal) {
ranX = Math.ceil(Math.random() * 2);
ranY = Math.ceil(Math.random() * 2);
ranZ = Math.ceil(Math.random() * 2);
tile = _level0.cube["layer_" + ranZ][(("t_" + ranX) + "_") + ranY];
game.currentTile = tile;
makeMove();
m++;
}
randomArray = getCustomMap();
game.Mode = "playRandom";
}
cubeMap0 = [[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]]];
cubeMap1 = [[[2, 1, 2], [1, 1, 1], [2, 1, 2]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[2, 1, 2], [1, 1, 1], [2, 1, 2]]];
cubeMap2 = [[[2, 1, 1], [2, 2, 2], [1, 1, 2]], [[1, 1, 2], [1, 2, 1], [2, 1, 1]], [[2, 1, 1], [2, 2, 2], [1, 1, 2]]];
cubeMap3 = [[[1, 1, 1], [1, 2, 1], [1, 1, 2]], [[1, 1, 2], [1, 2, 2], [2, 2, 2]], [[1, 2, 1], [2, 2, 1], [1, 1, 2]]];
cubeMap4 = [[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[1, 1, 2], [1, 1, 1], [2, 1, 2]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]]];
cubeMap5 = [[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[1, 2, 1], [2, 1, 2], [1, 2, 1]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]]];
cubeMap6 = [[[2, 2, 2], [2, 1, 2], [2, 2, 2]], [[2, 2, 2], [2, 1, 2], [2, 2, 2]], [[2, 2, 2], [2, 1, 2], [2, 2, 2]]];
cubeMap7 = [[[1, 1, 1], [2, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 2, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 2], [1, 1, 1]]];
cubeMap8 = [[[1, 1, 2], [1, 1, 2], [2, 2, 1]], [[1, 2, 1], [2, 1, 1], [1, 1, 1]], [[1, 1, 2], [1, 1, 2], [2, 2, 1]]];
cubeMap9 = [[[2, 2, 2], [2, 2, 2], [2, 2, 2]], [[1, 1, 1], [1, 2, 1], [1, 1, 1]], [[2, 2, 2], [2, 2, 2], [2, 2, 2]]];
cubeMap10 = [[[1, 1, 1], [1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 2, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]]];
cubeMap11 = [[[2, 1, 2], [1, 2, 1], [2, 1, 2]], [[1, 2, 1], [2, 2, 2], [1, 2, 1]], [[2, 1, 2], [1, 2, 1], [2, 1, 2]]];
cubeMap12 = [[[2, 1, 1], [1, 1, 1], [1, 1, 2]], [[2, 2, 2], [2, 1, 2], [2, 2, 2]], [[1, 1, 2], [1, 1, 1], [2, 1, 1]]];
cubeMap13 = [[[2, 1, 2], [1, 1, 1], [2, 1, 2]], [[2, 1, 1], [1, 2, 1], [1, 1, 2]], [[2, 1, 2], [1, 1, 1], [2, 1, 2]]];
cubeMap14 = [[[2, 2, 2], [2, 2, 2], [2, 2, 2]], [[2, 1, 2], [2, 1, 2], [2, 1, 2]], [[2, 2, 2], [2, 2, 2], [2, 2, 2]]];
cubeMap15 = [[[2, 1, 1], [1, 1, 1], [2, 1, 2]], [[1, 2, 2], [2, 1, 2], [2, 2, 1]], [[2, 1, 2], [1, 1, 1], [1, 1, 2]]];
cubeMap16 = [[[2, 1, 2], [1, 1, 1], [2, 1, 2]], [[2, 1, 2], [1, 1, 1], [2, 1, 2]], [[1, 1, 1], [2, 2, 2], [1, 1, 1]]];
if (game.Mode == "playCustom") {
buildCube(game.currentMap);
} else if (game.Mode == "normal") {
buildCube(_root["cubeMap" + game.currentMap]);
} else if (game.Mode == "makeCustom") {
buildCube(cubeMap0);
} else if (game.Mode == "random") {
buildCube(cubeMap0);
randomMoves();
}
onEnterFrame = function () {
detectKeys();
if (game.active) {
dy3 = cube.layer_0._y - layersY[0];
if (dy3 < 0) {
cube.layer_0._y = cube.layer_0._y - (dy3 * 0.1);
} else {
cube.layer_0._y = layersY[0];
}
if (game.currentLayer == 0) {
dy = cube.layer_2._y - (layersY[2] - 120);
if (dy > 0) {
cube.layer_2._y = cube.layer_2._y - (dy * 0.1);
} else {
cube.layer_2._y = layersY[2] - 120;
}
dy2 = cube.layer_1._y - (layersY[1] - 120);
if (dy2 > 0) {
cube.layer_1._y = cube.layer_1._y - (dy2 * 0.1);
} else {
cube.layer_1._y = layersY[1] - 120;
}
} else if (game.currentLayer == 1) {
dy = cube.layer_2._y - (layersY[2] - 120);
if (dy > 0) {
cube.layer_2._y = cube.layer_2._y - (dy * 0.1);
} else {
cube.layer_2._y = layersY[2] - 120;
}
dy2 = cube.layer_1._y - layersY[1];
if (dy2 < 0) {
cube.layer_1._y = cube.layer_1._y - (dy2 * 0.1);
} else {
cube.layer_1._y = layersY[1];
}
} else if (game.currentLayer == 2) {
dy = cube.layer_2._y - layersY[2];
if (dy < 0) {
cube.layer_2._y = cube.layer_2._y - (dy * 0.1);
} else {
cube.layer_2._y = layersY[2];
}
dy2 = cube.layer_1._y - layersY[1];
if (dy2 < 0) {
cube.layer_1._y = cube.layer_1._y - (dy2 * 0.1);
} else {
cube.layer_1._y = layersY[1];
}
}
}
};
saveCustom.btn.onRelease = function () {
_root.attachMovie("save_page", "savePage", 100);
savePage._x = Stage.width / 2;
savePage._y = Stage.height / 2;
saveCustom._y = saveCustom._y - 100;
i = 1;
while (i < 6) {
list = savePage["name" + i];
if (_root["customMap" + i].name != undefined) {
list.text = _root["customMap" + i].name;
}
i++;
}
savePage.btn1.onRelease = function () {
saveCustomMap(1, savePage.name1.text);
};
savePage.btn2.onRelease = function () {
saveCustomMap(2, savePage.name2.text);
};
savePage.btn3.onRelease = function () {
saveCustomMap(3, savePage.name3.text);
};
savePage.btn4.onRelease = function () {
saveCustomMap(4, savePage.name4.text);
};
savePage.btn5.onRelease = function () {
saveCustomMap(5, savePage.name5.text);
};
savePage.cancel_btn.onRelease = function () {
removeMovieClip(savePage);
saveCustom._y = saveCustom._y + 100;
};
};
Quit.btn.onRelease = function () {
removeMovieClip(cube);
removeMovieClip(Quit);
removeMovieClip(Reset);
removeMovieClip(info);
removeMovieClip(saveCustom);
removeMovieClip(savePage);
removeMovieClip(winPage);
gotoAndStop ("menu");
};
Reset.btn.onRelease = function () {
game.totalMoves = 0;
info.moves.text = "0";
if (game.Mode == "playCustom") {
buildCube(game.currentMap);
} else if (game.Mode == "normal") {
buildCube(_root["cubeMap" + game.currentMap]);
} else if (game.Mode == "makeCustom") {
buildCube(cubeMap0);
} else if (game.Mode == "playRandom") {
buildCube(randomArray);
}
};
Symbol 10 Button
on (release) {
_root.loader.targetY = Stage.height + _parent._height;
}
Symbol 11 MovieClip [loader] Frame 1
stop();
Symbol 11 MovieClip [loader] Frame 26
stop();
Symbol 15 Button
on (release) {
_root.makeMove();
}
on (rollOver) {
_root.game.currentTile = this;
}
Symbol 17 MovieClip [tile] Frame 1
stop();
Symbol 17 MovieClip [tile] Frame 2
stop();
Symbol 97 MovieClip [error_message] Frame 1
display_txt.text = "";
stop();