Frame 1
function displayLogo() {
logoFormat = new TextFormat();
logoFormat.font = "Eras";
logoFormat.size = 64;
logoFormat.color = 16777215 /* 0xFFFFFF */;
createEmptyMovieClip("logo", 50000);
var txt = "GRAVITUDE".split("");
var i = 0;
while (i < txt.length) {
var clip = logo.createEmptyMovieClip("txt" + i, i);
clip.createTextField("label", 1, 0, 0, 100, 20);
clip.label.setNewTextFormat(logoFormat);
clip.label.text = txt[i];
clip.label.embedFonts = true;
clip.label.selectable = false;
clip.label.autoSize = true;
clip.label._x = clip.label._x - (clip.label._width / 2);
clip.label._y = clip.label._y - (clip.label._height / 2);
clip.createTextField("labelBG", 0, 0, 0, 100, 20);
clip.labelBG.setNewTextFormat(logoFormat);
clip.labelBG.textColor = 6710886 /* 0x666666 */;
clip.labelBG.text = txt[i];
clip.labelBG.embedFonts = true;
clip.labelBG.selectable = false;
clip.labelBG.autoSize = true;
clip.labelBG._x = clip.label._x + 2;
clip.labelBG._y = clip.label._y + 2;
clip.wid = clip._width;
clip.hei = clip._height;
clip._x = (logo["txt" + (i - 1)]._x + (logo["txt" + (i - 1)].wid / 2)) + (clip.wid / 2);
clip.delay = i * 4;
clip.goal = 50 + (Math.abs(i - (txt.length / 2)) * 10);
clip._xscale = (clip._yscale = (clip._alpha = 0));
clip.onEnterFrame = function () {
this.delay--;
if (this.delay <= 0) {
this.veloc = this.veloc + ((this.goal - this._xscale) * 0.1);
this.veloc = this.veloc * 0.98;
this._alpha = (this._xscale = (this._yscale = this._yscale + this.veloc));
if (Math.abs(this._xscale - this.goal) < 0.1) {
this._alpha = (this._xscale = (this._yscale = this.goal));
delete this.onEnterFrame;
}
}
};
i++;
}
logo._x = 220 - (logo._width / 2);
logo._y = 60;
}
function removeExtras() {
removeMovieClip(logo);
removeMovieClip(titleScreen.scoreList);
}
function initializeMusicAndBG() {
toSave = {};
toSave.version = "v0.96";
var url = _url.split("/");
toSave.folder = url.splice(0, url.length - 1).join("/");
toSave.loadingFormat = new TextFormat();
toSave.loadingFormat.font = "Eras";
toSave.loadingFormat.size = 10;
toSave.loadingFormat.align = "center";
toSave.loadingFormat.color = 3342336 /* 0x330000 */;
toSave.scoresFile = "http://flash.isnan.net/gravitude/gravitude.php";
toSave.replayDir = "http://flash.isnan.net/gravitude/replay/";
toSave.musicDir = toSave.folder + "/music/";
toSave.musicTracks = ["rain.mp3", "pressure.mp3"];
toSave.musicIndex = random(toSave.musicTracks.length);
toSave.backgroundDir = toSave.folder + "/bg/";
toSave.backgrounds = ["sunset.jpg", "lake.jpg", "blue.jpg", "beehive.jpg", "pond.jpg", "xray.jpg", "warp.jpg", "dream.jpg", "radiation.jpg", "seafloor.jpg", "slipstream.jpg"];
toSave.backgroundIndex = random(toSave.backgrounds.length);
var getVer = new LoadVars();
getVer.load("http://flash.isnan.net/gravitude/version.txt");
getVer.onLoad = function (success) {
if (success) {
var thisVer = Number(toSave.version.substr(1, toSave.version.length - 1));
var latestVer = Number(this.version.substr(1, this.version.length - 1));
if (toSave.version >= this.version) {
toSave.outOfDate = false;
} else {
titleScreen.versionStatus._visible = true;
toSave.outOfDate = true;
}
} else {
toSave.outOfDate = false;
}
};
createEmptyMovieClip("bg", 0);
bg.depth = 0;
bg.createEmptyMovieClip("bgLoadBar", 999999);
fillLoadBar(bg.bgLoadBar);
bg.bgLoadBar._x = -bg.bgLoadBar._width;
bg.bgLoadBar._y = 370;
bg.createEmptyMovieClip("musicLoadBar", 999998);
fillLoadBar(bg.musicLoadBar);
bg.musicLoadBar._x = -bg.musicLoadBar._width;
bg.musicLoadBar._y = 420;
loadMusic();
loadBG();
}
function fillLoadBar(src) {
var wid = 105;
var hei = 40;
src.createEmptyMovieClip("bg", 0);
with (src.bg) {
beginFill(16777215, 20);
lineTo(wid, 0);
lineTo(wid, hei);
lineTo(0, hei);
endFill();
}
src.createEmptyMovieClip("bar", 1);
src.bar._x = 5;
src.bar._y = hei - 15;
with (src.bar) {
beginFill(16711680, 50);
lineTo(wid - 10, 0);
lineTo(wid - 10, 10);
lineTo(0, 10);
endFill();
}
src.createEmptyMovieClip("barTop", 2);
src.barTop._x = src.bar._x;
src.barTop._y = src.bar._y;
with (src.barTop) {
lineStyle(1);
lineTo(wid - 10, 0);
lineTo(wid - 10, 10);
lineTo(0, 10);
lineTo(0, 0);
}
src.createTextField("label", 10, 5, 0, wid - 10, 40);
src.label.setNewTextFormat(toSave.loadingFormat);
src.label.selectable = false;
src.label.embedFonts = true;
src.label.multiline = true;
}
function loadMusic() {
bg.musicLoadBar.bar._xscale = 0;
bg.musicLoadBar.label.text = "streaming music:\n" + convertFilename(toSave.musicTracks[toSave.musicIndex]);
bg.musicLoadBar.onEnterFrame = easeBarIn;
bg.createEmptyMovieClip("musicLoad", 999997);
bg.musicLoad.onEnterFrame = function () {
var per = (toSave.music.getBytesLoaded() / toSave.music.getBytesTotal());
bg.musicLoadBar.bar._xscale = per * 100;
if (per == 1) {
bg.musicLoadBar.onEnterFrame = easeBarOut;
removeMovieClip(this);
}
};
toSave.music = new Sound(_root);
toSave.music.loadSound(toSave.musicDir + toSave.musicTracks[toSave.musicIndex], true);
toSave.music.onSoundComplete = function () {
toSave.musicIndex++;
if (toSave.musicIndex == toSave.musicTracks.length) {
toSave.musicIndex = 0;
}
loadMusic();
};
}
function loadBG() {
bg.bgLoadBar.bar._xscale = 0;
bg.bgLoadBar.label.text = "loading bg:\n" + convertFilename(toSave.backgrounds[toSave.backgroundIndex]);
bg.bgLoadBar.onEnterFrame = easeBarIn;
var clip = bg.createEmptyMovieClip("bg" + bg.depth, bg.depth++);
clip.createEmptyMovieClip("hold", 0);
var path = (toSave.backgroundDir + toSave.backgrounds[toSave.backgroundIndex]);
clip.hold.loadMovie(path);
clip._alpha = 0;
clip.onEnterFrame = function () {
var per = (this.hold.getBytesLoaded() / this.hold.getBytesTotal());
bg.bgLoadBar.bar._xscale = per * 100;
if (per == 1) {
bg.bgLoadBar.onEnterFrame = easeBarOut;
this._alpha = this._alpha + 10;
if (this._alpha >= 100) {
delete this.onEnterFrame;
removeMovieClip(bg["bg" + this.getDepth()]);
}
}
};
do {
var index = random(toSave.backgrounds.length);
} while (toSave.backgroundIndex == index);
toSave.backgroundIndex = index;
}
function easeBarIn() {
this._x = this._x * 0.3;
if (this._x > -0.1) {
this._x = 0;
delete this.onEnterFrame;
}
}
function easeBarOut() {
this._x = this._x + (((-this._width) - this._x) * 0.3);
if (Math.abs(this._x - this._width) < 0.1) {
this._x = -this._width;
delete this.onEnterFrame;
}
}
function convertFilename(str) {
var name = str.split(".")[0];
return(name.charAt(0).toUpperCase() + name.substr(1, name.length - 1));
}
function loadHighScores(gametype) {
if (titleScreen.scoreList != undefined) {
titleScreen.loading._visible = true;
removeMovieClip(titleScreen.scoreList);
}
toSave.scoreList = new LoadVars();
toSave.scoreList.action = "view";
toSave.scoreList.rand = random(99999);
toSave.scoreList.gametype = gametype;
toSave.scoreList.sendAndLoad(toSave.scoresFile, toSave.scoreList, "POST");
toSave.scoreList.onLoad = function (success) {
if (success) {
if (_currentframe == 1) {
titleScreen.gametype = this.gametype;
titleScreen.displayHighScores(this.scores);
} else if (_currentframe == 2) {
hud.highScore.transferScores(this.scores);
}
} else {
trace("error loading scores");
}
};
}
function saveHighScore(name, score, level, spheres, time, replay, gametype, sortNum) {
toSave.scoreSave = new LoadVars();
toSave.scoreSave.action = "save";
toSave.scoreSave.rand = random(99999);
toSave.scoreSave.name = name;
toSave.scoreSave.score = score;
toSave.scoreSave.level = level;
toSave.scoreSave.spheres = spheres;
toSave.scoreSave.time = time;
toSave.scoreSave.replay = replay;
toSave.scoreSave.gametype = gametype;
toSave.scoreSave.sortNum = sortNum;
toSave.scoreSave.sendAndLoad(toSave.scoresFile, toSave.scoreSave, "POST");
toSave.scoreSave.onLoad = function (success) {
if (success) {
if (_currentframe == 2) {
hud.highScore.gotoAndStop(4);
}
} else {
trace("error saving score");
}
};
}
stop();
titleScreen.swapDepths(1);
Stage.showMenu = false;
tutStr = "0-602201;61-623213;217-01;223-00;235-21;238-20;243-21;246-20;253-31;256-30;258-31;262-30;271-31;274-30;282-11;284-10;328-653210;338-01;365-00;393-11;395-10;432-31;435-30;439-610112;470-01;494-00;518-11;519-10;609-643011;614-31;617-30;621-31;625-30;629-31;632-30;656-21;658-20;664-01;689-00;705-11;708-10;796-641333;907-41;910-40;933-31;935-30;939-31;942-30;959-01;967-00;987-11;989-10;1027-21;1030-20;1033-643122;1040-01;1069-00;1079-11;1082-10;1170-643330;1286-41;1288-40;1297-31;1300-30;1303-31;1305-30;1317-21;1320-20;1330-01;1342-00;1354-11;1357-10;1400-632333;1419-21;1422-20;1427-01;1446-00;1490-11;1492-10;1626-653223;1704-31;1707-30;1712-31;1716-30;1725-01;1738-00;1770-01;1772-00;1796-11;1799-10;1887-651133;1887-01;1912-00;1922-11;1925-10;1968-662122;1993-41;1996-40;2001-21;2003-20;2016-21;2019-20;2021-01;2039-00;2048-01;2051-00;2068-11;2071-10;2153-41;2156-40;2159-603321;2167-01;2183-00;2206-41;2209-40;2212-31;2215-30;2218-31;2221-30;2244-11;2247-10;2290-620320;2358-21;2361-20;2385-21;2387-20;2394-01;2404-00;2425-11;2428-10;2606-621323;2641-21;2643-20;2692-01;2698-00;2738-51;2759-01;2768-00;2791-11;2794-10;2800-50;2847-641101;2881-41;2883-40;2902-31;2906-30;3011-11;3014-10;3099-21;3103-642100;3103-20;3108-01;3135-00;3142-11;3145-10;3189-631212;3205-01;3210-00;3224-31;3227-30;3257-21;3261-20;3265-21;3268-20;3280-01;3289-00;3311-11;3314-10;3403-653233;3410-41;3413-40;3421-21;3424-20;3435-01;3441-00;3481-01;3487-00;3519-51;3524-31;3525-30;3526-01;3537-00;3544-01;3552-00;3578-01;3582-00;3599-11;3603-10;3620-50;3666-643020;3776-21;3780-20;3790-01;3793-00;3802-11;3805-10;3874-41;3877-40;3881-31;3884-30;3888-01;3894-642103;3917-00;3935-11;3938-10;3979-01;3982-620313;3987-31;3989-00;3990-01;3991-30;3994-31;3996-30;4006-00;4013-01;4015-00;4026-11;4028-10;4163-610311;";
tutorial = false;
if (toSave == undefined) {
titleScreen.versionStatus._visible = false;
initializeMusicAndBG();
} else {
loadBG();
titleScreen.versionStatus._visible = toSave.outOfDate;
}
titleScreen.version = toSave.version;
titleScreen.versionBG = titleScreen.version;
displayLogo();
Frame 2
function initialize() {
removeMovieClip(titleScreen);
framerate = 31;
shapes = [];
shapes[0] = [[0, 0], [1, 0], [1, 1], [0, 1]];
shapes[1] = [[0, 0], [1, 0], [2, 0], [1, 1]];
shapes[2] = [[0, 0], [1, 0], [2, 0], [2, 1]];
shapes[3] = [[0, 0], [0, 1], [0, 2], [1, 2]];
shapes[4] = [[0, 0], [1, 0], [2, 0], [3, 0]];
shapes[5] = [[0, 0], [1, 0], [1, 1], [2, 1]];
shapes[6] = [[0, 0], [0, 1], [1, 1], [1, 2]];
clrs = [16711680, 39168, 255, 16776960, 10027263, 16750848, 16751103, 6697728, 16777215, 6710886];
clrsToUse = 4;
sqrSize = 25;
moveDelay = 45;
var soundFX = ["fxRotate", "fxLand", "FxCombo1", "fxCombo2", "fxCombo3", "fxCombo4", "fxLevelUp", "fxFocusEnter", "fxFocusExit"];
var i = 0;
while (i < soundFX.length) {
_root[soundFX[i]] = new Sound(_root);
_root[soundFX[i]].attachSound(soundFX[i]);
i++;
}
fxLand.setVolume(50);
hud.swapDepths(999);
scoreFormat1 = new TextFormat();
scoreFormat1.font = "Eras";
scoreFormat1.size = 16;
scoreFormat1.color = 16768477 /* 0xFFDDDD */;
scoreFormat2 = new TextFormat();
scoreFormat2.font = "Eras";
scoreFormat2.size = 20;
scoreFormat2.color = 16755370 /* 0xFFAAAA */;
scoreFormat3 = new TextFormat();
scoreFormat3.font = "Eras";
scoreFormat3.size = 24;
scoreFormat3.color = 16737894 /* 0xFF6666 */;
scoreFormat4 = new TextFormat();
scoreFormat4.font = "Eras";
scoreFormat4.size = 28;
scoreFormat4.color = 16711680 /* 0xFF0000 */;
tutorialText = [];
tutorialText[0] = {frame:0, txt:"Welcome to Gravitude. The object of Gravitude is to connect four spheres of the same color."};
tutorialText[1] = {frame:160, txt:"Hold the RIGHT key to move the shape quicker. Z and X will rotate the shape. Press UP or DOWN to drop it."};
tutorialText[2] = {frame:400, txt:"Connecting four or more spheres of the same color will eliminate them. All other spheres above those eliminated will drop to the center line."};
tutorialText[3] = {frame:800, txt:"Pressing C will toggle your shape's position above or below the center line."};
tutorialText[4] = {frame:1100, txt:"Use this to reach spheres that are otherwise inaccessable."};
tutorialText[5] = {frame:1400, txt:"With careful planning, you can create combos. Powerful combos will provide point multipliers."};
tutorialText[6] = {frame:2600, txt:"As you perform combos, your focus meter will build. Hold SPACE to activate focus mode and slow down time."};
tutorialText[7] = {frame:3400, txt:"Rotating pieces while in focus mode will slow down time even further and allow to you perform stunt moves."};
tutorialText[8] = {frame:3850, txt:"After enough points, you will gain a level. This will increase the amount of points spheres are worth, but it will also gradually increase the game speed."};
tutorialText[9] = {frame:4150, txt:"If an object ever reaches the right edge of the game area, you lose."};
tutorialText[10] = {frame:4300, txt:"End of tutorial. Press Main Menu to go back."};
tutorialText[11] = {frame:4400, txt:""};
pauseWatch = {};
pauseWatch.onKeyDown = function () {
if (Key.isDown(13)) {
paused = !paused;
if (!replay) {
squares._visible = !paused;
hud.pausedMC._visible = paused;
}
}
};
Key.addListener(pauseWatch);
loadBG();
newGame(gameStr);
}
function newGame(gameStr) {
delete currentShape;
delete nextShape;
makeGrid();
hud.versionWarning._visible = toSave.outOfDate;
hud.highScore._visible = false;
createEmptyMovieClip("squares", 9);
createEmptyMovieClip("funnel", 10);
createEmptyMovieClip("particles", 20);
createEmptyMovieClip("scores", 21);
createEmptyMovieClip("focusHue", 100);
funnel.pos = 1;
squares._x = (funnel._x = (particles._x = (scores._x = grid._x)));
squares._y = (funnel._y = (particles._y = (scores._y = grid._y)));
squares.toRemove = [];
squares.xPos = [];
squares.depth = 999999 /* 0x0F423F */;
squares.multi = [];
scores.depth = 0;
particles.depth = 0;
focus = 1;
curFocus = 0;
hud.focusBar._xscale = 0;
newPiece = 0;
paused = false;
hud.pausedMC._visible = false;
hud.tutorialMC._visible = tutorial;
gameSpeed = 1;
hud.gametype = convertFilename(gametype);
hud.gametypeBG = hud.gametype;
hud.score = 0;
hud.scoreBG = hud.score;
hud.level = 1;
hud.levelBG = hud.level;
hud.spheres = 0;
hud.spheresBG = hud.spheres;
speed = 0.75 + ((hud.level % 15) * 0.6);
tutIndex = 0;
recordStr = "";
if (gametype == "endurance") {
frame = 0;
} else if (gametype == "timed") {
frame = (framerate * 3) * 60;
} else if (gametype == "dash") {
frame = 0;
}
focusGoalPrev = 1;
rightPressed = false;
dropPressed = false;
zPressed = false;
xPressed = false;
cPressed = false;
spacePressed = false;
typeArr = ["rightPressed", "dropPressed", "zPressed", "xPressed", "cPressed", "spacePressed"];
funnel.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
gameLoop();
i++;
}
}
};
if (gameStr != undefined) {
replay = true;
replayIndex = 0;
if (replayArr == undefined) {
replayArr = gameStr.split(";");
var i = 0;
while (i < (replayArr.length - 1)) {
var detail = replayArr[i].split("-");
var frame = Number(detail[0]);
var type = Number(detail[1].charAt(0));
var content = detail[1].substr(1, detail[1].length - 1);
replayArr[i] = {frame:frame, type:type, content:content};
i++;
}
replayEnd = replayArr[i - 1].frame;
}
if (gametype == "timed") {
replayEnd = _root.frame;
}
hud.replayMC.totalTime = framesToTime(replayEnd);
hud.replayMC.totalTimeBG = hud.replayMC.totalTime;
hud.replayMC._visible = true;
} else {
replay = false;
hud.replayMC._visible = false;
}
hud.focusBar.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
this._xscale = this._xscale + ((curFocus - this._xscale) * 0.2);
i++;
}
}
};
with (focusHue) {
beginFill(10053120);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
endFill();
}
focusHue._alpha = 0;
}
function makeGrid() {
gridArr = [];
gridWidth = 16;
gridHeight = 6;
createEmptyMovieClip("grid", 5);
grid.createEmptyMovieClip("bg", 0);
with (grid.bg) {
beginFill(16777215, 20);
lineTo(gridWidth * sqrSize, 0);
lineTo(gridWidth * sqrSize, (gridHeight * sqrSize) * 2);
lineTo(0, (gridHeight * sqrSize) * 2);
endFill();
}
grid.createEmptyMovieClip("lines", 1);
grid.lines.lineStyle(1, 0, 30);
var x = 0;
while (x <= (sqrSize * gridWidth)) {
with (grid.lines) {
moveTo(x, 0);
lineTo(x, (gridHeight * 2) * sqrSize);
}
x = x + sqrSize;
}
var y = 0;
while (y <= ((sqrSize * gridHeight) * 2)) {
with (grid.lines) {
moveTo(0, y);
lineTo(gridWidth * sqrSize, y);
}
y = y + sqrSize;
}
with (grid) {
lineStyle(15, 0, 5);
moveTo((-sqrSize) * 4, (-sqrSize) * 2);
lineTo((-sqrSize) * 4, ((gridHeight * sqrSize) * 2) + (sqrSize * 2));
}
var x = 0;
while (x < gridWidth) {
gridArr[x] = [];
var y = 0;
while (y < (gridHeight * 2)) {
gridArr[x][y] = -1;
y++;
}
x++;
}
createEmptyMovieClip("gridLine", 6);
with (gridLine) {
lineStyle(2, 0, 50);
moveTo(0, gridHeight * sqrSize);
lineTo(gridWidth * sqrSize, gridHeight * sqrSize);
}
grid._x = (gridLine._x = Stage.width - (sqrSize * (2 + gridWidth)));
grid._y = (gridLine._y = sqrSize * 4);
drawGridCircle((-sqrSize) * 4, (-sqrSize) * 2, 0);
drawGridCircle((-sqrSize) * 4, ((gridHeight * sqrSize) * 2) + (sqrSize * 2), 1);
}
function drawGridCircle(x, y, depth) {
var rad = 30;
var clip = grid.createEmptyMovieClip("circle" + depth, depth + 1000);
clip._x = x;
clip._y = y;
with (clip) {
var matrix = {matrixType:"box", x:-rad, y:-rad, w:rad * 2, h:rad * 2, r:0};
beginGradientFill("radial", [0, 0, 0], [5, 10, 0], [0, 220, 255], matrix);
moveTo(rad * 1, rad * 0);
var angle = 0.196349540849362;
while (angle <= (Math.PI*2)) {
lineTo(rad * Math.cos(angle), rad * Math.sin(angle));
angle = angle + 0.196349540849362;
}
endFill();
}
clip.goal = 80;
clip.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
this.veloc = this.veloc + ((this.goal - this._xscale) * (hud.level / 100));
this._xscale = (this._yscale = this._yscale + this.veloc);
if (this._xscale < 0) {
removeMovieClip(this);
}
i++;
}
}
};
clip.attachMovie("pulse", "pulse", 0);
clip.pulse._xscale = (clip.pulse._yscale = (clip.pulse._alpha = 0));
}
function drawShape(presetType, presetColorArr) {
squares.combo = 0;
var type = ((presetType == undefined) ? (random(shapes.length)) : (presetType));
var clip = funnel.createEmptyMovieClip("square" + squares.depth, squares.depth--);
var shapeStr = String(type);
var i = 0;
while (i < shapes[type].length) {
var square = clip.createEmptyMovieClip("square" + i, i);
square._x = shapes[type][i][0] * sqrSize;
square._y = shapes[type][i][1] * sqrSize;
if (presetColorArr == undefined) {
var index = random(clrsToUse);
} else {
var index = presetColorArr[i];
}
shapeStr = shapeStr + index;
drawSquare(square, clrs[index], 0);
i++;
}
recordInput(6 + shapeStr);
var wid = clip._width;
var hei = clip._height;
for (var i in clip) {
clip[i]._x = clip[i]._x - (wid / 2);
clip[i]._y = clip[i]._y - (hei / 2);
}
clip._x = (-sqrSize) * 4;
clip._y = (gridHeight * sqrSize) - (((gridHeight * sqrSize) + (sqrSize * 2)) * funnel.pos);
clip._xscale = (clip._yscale = 0);
clip.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
if ((currentShape._x > ((-sqrSize) * 2)) || (currentShape == undefined)) {
this.veloc = this.veloc + ((100 - this._xscale) * 0.3);
this.veloc = this.veloc * 0.75;
this._xscale = (this._yscale = this._yscale + this.veloc);
if (Math.abs(this._xscale - 100) < 0.1) {
delete this.onEnterFrame;
}
}
i++;
}
}
};
clip.switchY1 = (clip.switchY2 = clip._y);
clip.rotateFrame = 0;
clip.rotateEnd = 0;
clip.rotGoal = 0;
clip.switchFrame = 0;
clip.switchEnd = 0;
return(clip);
}
function drawSquare(src, clr, rot, skipLine) {
src.clr = clr;
var corner = (sqrSize / 2);
with (src) {
clear();
if (skipLine == undefined) {
lineStyle(1);
}
var startX;
var startY;
var off = (sqrSize / 6);
rot = rot * -1;
if (rot < 0) {
rot = rot + 360;
}
if (rot == 0) {
startX = -off;
startY = -off;
} else if (rot == 90) {
startX = off;
startY = -off;
} else if (rot == 180) {
startX = off;
startY = off;
} else if (rot == 270) {
startX = -off;
startY = off;
}
var matrix = {matrixType:"box", x:startX, y:startY, w:sqrSize, h:sqrSize, r:0};
var ltClr = hexToRGB(clr);
for (var i in ltClr) {
ltClr[i] = ltClr[i] + 100;
if (ltClr[i] > 255) {
ltClr[i] = 255;
}
}
var ltRGB = rgbToHex(ltClr.r, ltClr.g, ltClr.b);
var darkClr = hexToRGB(clr);
for (var i in darkClr) {
darkClr[i] = darkClr[i] - 100;
if (darkClr[i] < 0) {
darkClr[i] = 0;
}
}
var darkRGB = rgbToHex(darkClr.r, darkClr.g, darkClr.b);
beginGradientFill("radial", [ltRGB, clr, darkRGB], [100, 100, 100], [50, 200, 255], matrix);
moveTo(corner, 0);
curveTo(sqrSize, 0, sqrSize, corner);
curveTo(sqrSize, sqrSize, sqrSize - corner, sqrSize);
curveTo(0, sqrSize, 0, sqrSize - corner);
curveTo(0, 0, corner, 0);
endFill();
}
}
function findOrder(src, dir) {
var order = [];
var rot = (Math.round(src._rotation / 90) * 90);
var error = [];
for (var i in src) {
if (typeof(src[i]) == "movieclip") {
var coord = convertCoords(src[i]._x, src[i]._y, rot);
var x = coord[0];
var y = coord[1];
var hei = 1;
for (var j in src) {
if ((typeof(src[j]) == "movieclip") && (i != j)) {
var otherCoord = convertCoords(src[j]._x, src[j]._y, rot);
if (Math.round(otherCoord[0] / sqrSize) == Math.round(x / sqrSize)) {
hei++;
}
}
}
var rX = Math.round(x / sqrSize);
if ((((x < ((-sqrSize) / 2)) || (x > ((gridWidth * sqrSize) + (sqrSize / 2)))) || ((dir == -1) && (gridArr[rX][(gridHeight * 2) - hei] != -1))) || ((dir == 1) && (gridArr[rX][hei - 1] != -1))) {
var eX = rX;
var eY = (gridHeight - (gridHeight * dir));
var found = false;
var j = 0;
while (j < error.length) {
if (error[j][0] == eX) {
found = true;
break;
}
j++;
}
if (!found) {
error.push([eX, eY]);
}
}
order.push({obj:src[i], x:x, y:y});
}
}
fieldSort(order, "y", dir);
return({order:order, error:error});
}
function placeShape(dir) {
var results = findOrder(currentShape, dir);
if (results.error.length > 0) {
var i = 0;
while (i < results.error.length) {
makeError(results.error[i][0], results.error[i][1]);
i++;
}
return(undefined);
}
var i = 0;
while (i < results.order.length) {
var clip = squares.createEmptyMovieClip("square" + squares.depth, squares.depth--);
clip._x = results.order[i].x;
clip._y = results.order[i].y;
clip.dir = dir;
drawSquare(clip, results.order[i].obj.clr, 0);
var x = Math.round(clip._x / sqrSize);
var y = Math.round(clip._y / sqrSize);
var goal = ((dir == 1) ? (gridHeight) : (gridHeight - 1));
do {
y = y + dir;
} while (((gridArr[x][y] == -1) || (gridArr[x][y] == undefined)) && (y != goal));
y = y - dir;
gridArr[x][y] = clip;
moveSquare(clip, x, y);
delete results.order[i].obj.hint.src;
i++;
}
newPiece = moveDelay;
removeMovieClip(currentShape);
delete currentShape;
}
function convertCoords(x, y, rot) {
var coord = {x:x, y:y};
currentShape.localToGlobal(coord);
if (rot == 0) {
var offX = 0;
var offY = 0;
} else if (rot == 90) {
var offX = (-sqrSize);
var offY = 0;
} else if ((rot == 180) || (rot == -180)) {
var offX = (-sqrSize);
var offY = (-sqrSize);
} else if (rot == -90) {
var offX = 0;
var offY = (-sqrSize);
}
var x = ((coord.x - squares._x) + offX);
var y = ((coord.y - squares._y) + offY);
return([x, y]);
}
function moveSquare(clip, x, y) {
clip.xgoal = x * sqrSize;
clip.ygoal = y * sqrSize;
clip.easeFrame = 0;
clip.endFrame = (moveDelay - 10) - random(15);
clip.finish = moveDelay - 10;
clip.startY = clip._y;
clip.x = x;
clip.y = y;
clip.bouncePlayed = 0;
clip.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
this.easeFrame = this.easeFrame + focus;
if (this.easeFrame < this.endFrame) {
if (Math.abs(this._x - this.xgoal) < 1) {
this._x = this.xgoal;
} else {
this._x = this._x + (((this.xgoal - this._x) * 0.3) * focus);
}
this._y = easeOutBounce(this.easeFrame, this.startY, this.ygoal - this.startY, this.endFrame);
if ((this.easeFrame >= (this.endFrame * 0.35)) && (this.bouncePlayed == 0)) {
this.bouncePlayed++;
fxLand.start();
} else if ((this.easeFrame >= (this.endFrame * 0.7)) && (this.bouncePlayed == 1)) {
this.bouncePlayed++;
fxLand.start();
}
} else if (this.easeFrame >= this.endFrame) {
this._x = this.xgoal;
this._y = this.ygoal;
}
if (this.easeFrame >= this.finish) {
findMatches(this.x, this.y);
delete this.onEnterFrame;
}
i++;
}
}
};
}
function fieldSort(whichArray, whichField, order) {
var temp = [];
var i = 0;
while (i < whichArray.length) {
temp.push([whichArray[i][whichField], whichArray[i]]);
i++;
}
((order == -1) ? (temp.sort(function (a, b) {
return(a[0] > b[0])})) : (temp.sort(function (a, b) {
return(a[0] < b[0])})));
var i = 0;
while (i < temp.length) {
whichArray[i] = temp[i][1];
i++;
}
}
function easeOutBounce(t, b, c, d) {
if (((t = t / d)) < 0.363636363636364) {
return((c * ((7.5625 * t) * t)) + b);
}
if (t < 0.727272727272727) {
return((c * (((7.5625 * ((t = t - 0.545454545454545))) * t) + 0.75)) + b);
}
if (t < 0.909090909090909) {
return((c * (((7.5625 * ((t = t - 0.818181818181818))) * t) + 0.9375)) + b);
}
return((c * (((7.5625 * ((t = t - 0.954545454545455))) * t) + 0.984375)) + b);
}
function easeInOutQuad(t, b, c, d) {
if (((t = t / (d / 2))) < 1) {
return((((c / 2) * t) * t) + b);
}
return((((-c) / 2) * (((--t) * (t - 2)) - 1)) + b);
}
function findMatches(x, y) {
var clr = gridArr[x][y].clr;
var toSearch = [{x:x, y:y}];
var visited = [];
var found = [gridArr[x][y]];
searchRecursive(clr, toSearch, visited, found);
}
function searchRecursive(clr, toSearch, visited, found) {
if (toSearch.length > 0) {
var coords = toSearch.pop();
visited.push(coords);
var angle = 0;
while (angle < (Math.PI*2)) {
var x = (coords.x + Math.round(Math.cos(angle)));
var y = (coords.y + Math.round(Math.sin(angle)));
if ((gridArr[x][y].clr == clr) && (clr != undefined)) {
var isFound = false;
var i = 0;
while (i < visited.length) {
if ((visited[i].x == x) && (visited[i].y == y)) {
isFound = true;
break;
}
i++;
}
if (!isFound) {
var i = 0;
while (i < toSearch.length) {
if ((toSearch[i].x == x) && (toSearch[i].y == y)) {
isFound = true;
break;
}
i++;
}
if (!isFound) {
toSearch.push({x:x, y:y});
found.push(gridArr[x][y]);
}
}
}
angle = angle + (Math.PI/2);
}
searchRecursive(clr, toSearch, visited, found);
} else if (found.length >= 4) {
if (squares.multi.length == 0) {
squares.combo++;
newPiece = newPiece + moveDelay;
var comboSound = ((squares.combo > 4) ? 4 : (squares.combo));
_root["fxCombo" + comboSound].start();
}
var xBounds = [];
var yBounds = [];
var i = 0;
while (i < found.length) {
if (xBounds[0] == undefined) {
xBounds[0] = found[i].x;
xBounds[1] = found[i].x;
} else if (found[i].x < xBounds[0]) {
xBounds[0] = found[i].x;
} else if (found[i].x > xBounds[1]) {
xBounds[1] = found[i].x;
}
if (yBounds[0] == undefined) {
yBounds[0] = found[i].y;
yBounds[1] = found[i].y;
} else if (found[i].y < yBounds[0]) {
yBounds[0] = found[i].y;
} else if (found[i].y > yBounds[1]) {
yBounds[1] = found[i].y;
}
var isFound = false;
var j = 0;
while (j < squares.xPos.length) {
if (found[i].x == squares.xPos[j]) {
isFound = true;
break;
}
j++;
}
if (!isFound) {
squares.xPos.push(found[i].x);
}
gridArr[found[i].x][found[i].y] = -1;
squares.toRemove.push(found[i]);
i++;
}
hud.spheres = hud.spheres + found.length;
hud.spheresBG = hud.spheres;
var calcScore = (found.length * (10 + ((hud.level - 1) * 2)));
squares.multi.push({calcScore:calcScore, x:(xBounds[0] + xBounds[1]) / 2, y:(yBounds[0] + yBounds[1]) / 2});
}
}
function makeError(x, y) {
var clip = particles.createEmptyMovieClip("error" + particles.depth, particles.depth++);
clip._x = x * sqrSize;
clip._y = y * sqrSize;
with (clip) {
lineStyle(5, 16711680);
lineTo(sqrSize, 0);
}
clip._alpha = 0;
clip.fadeIn = true;
clip.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
if (this.fadeIn) {
this._alpha = this._alpha + (20 * focus);
if (this._alpha >= 100) {
this.fadeIn = false;
}
} else {
this._alpha = this._alpha - (10 * focus);
if (this._alpha <= 0) {
removeMovieClip(this);
}
}
i++;
}
}
};
}
function levelPulse() {
var i = 0;
while (i < gameSpeed) {
this._xscale = (this._yscale = this._yscale + (20 * focus));
this._alpha = this._alpha - (3 * focus);
if (this._alpha <= 0) {
this._xscale = (this._yscale = (this._alpha = 0));
delete this.onEnterFrame;
}
i++;
}
}
function addScore(amount, txt, multiplier, midX, midY) {
if (multiplier > 1) {
curFocus = curFocus + (multiplier * 10);
if (curFocus > 100) {
curFocus = 100;
}
}
if (multiplier > 4) {
multiplier = 4;
}
hud.score = hud.score + amount;
hud.scoreBG = hud.score;
if ((Math.floor(hud.score / (500 + ((hud.level - 1) * 50))) + 1) > hud.level) {
fxLevelUp.start();
hud.level++;
hud.levelBG = hud.level;
if (((hud.level % 15) == 0) && (clrsToUse < 10)) {
clrsToUse++;
speed = 2;
} else if (speed < (sqrSize / 2)) {
speed = speed + 0.6;
}
grid.circle0.pulse._alpha = (grid.circle1.pulse._alpha = 100);
grid.circle0.pulse.onEnterFrame = levelPulse;
grid.circle1.pulse.onEnterFrame = levelPulse;
}
var clip = scores.createEmptyMovieClip("text" + scores.depth, scores.depth++);
clip.createTextField("label", 1, 0, 0, 100, 20);
clip.label.setNewTextFormat(_root["scoreFormat" + multiplier]);
clip.label.text = txt;
clip.label.selectable = false;
clip.label.embedFonts = true;
clip.label.autoSize = true;
clip.createTextField("bg", 0, 0, 0, 100, 20);
clip.bg.setNewTextFormat(_root["scoreFormat" + multiplier]);
clip.bg.textColor = 0;
clip.bg.text = txt;
clip.bg.selectable = false;
clip.bg.embedFonts = true;
clip.bg.autoSize = true;
clip.bg._x++;
clip.bg._y++;
clip._x = ((midX + 0.5) * sqrSize) - (clip._width / 2);
clip._y = ((midY + 0.5) * sqrSize) - (clip._height / 2);
clip.fadeIn = true;
clip._alpha = 0;
clip.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
this._y = this._y - (2 * focus);
if (this.fadeIn) {
this._alpha = this._alpha + (10 * focus);
if (this._alpha >= 100) {
this.fadeIn = false;
}
} else {
this._alpha = this._alpha - (2 * focus);
if (this._alpha <= 0) {
removeMovieClip(this);
}
}
i++;
}
}
};
}
function recordInput(key, pressed) {
if (!replay) {
var str = String(key);
if (pressed != undefined) {
str = str + Number(pressed);
}
recordStr = recordStr + (((frame + "-") + str) + ";");
}
}
function gameLoop() {
if (replay) {
while (replayArr[replayIndex].frame == frame) {
var type = replayArr[replayIndex].type;
var content = replayArr[replayIndex].content;
if (type < 6) {
_root[typeArr[type]] = Boolean(content);
} else {
var shapeIndex = content.charAt(0);
var colors = content.substr(1, 4).split("");
if (nextShape != undefined) {
currentShape = nextShape;
} else {
newPiece = 60;
}
nextShape = drawShape(shapeIndex, colors);
}
replayIndex++;
}
} else {
if (Math.ceil(newPiece) == 0) {
newPiece = -1;
if (nextShape != undefined) {
currentShape = nextShape;
} else {
newPiece = 60;
}
nextShape = drawShape();
} else if (newPiece > 0) {
newPiece = newPiece - focus;
}
if (Key.isDown(39) != rightPressed) {
rightPressed = !rightPressed;
recordInput(0, rightPressed);
}
if ((Key.isDown(38) || (Key.isDown(40))) != dropPressed) {
dropPressed = !dropPressed;
recordInput(1, dropPressed);
}
if (Key.isDown(90) != zPressed) {
zPressed = !zPressed;
recordInput(2, zPressed);
}
if (Key.isDown(88) != xPressed) {
xPressed = !xPressed;
recordInput(3, xPressed);
}
if (Key.isDown(67) != cPressed) {
cPressed = !cPressed;
recordInput(4, cPressed);
}
if (Key.isDown(32) != spacePressed) {
spacePressed = !spacePressed;
recordInput(5, spacePressed);
}
}
if (currentShape != undefined) {
if ((currentShape.switchFrame + focus) < currentShape.switchEnd) {
currentShape.switchFrame = currentShape.switchFrame + focus;
allowPlace = false;
currentShape._alpha = currentShape._alpha + (((30 - currentShape._alpha) * 0.5) * focus);
currentShape._xscale = (currentShape._yscale = currentShape._yscale + (((150 - currentShape._xscale) * 0.5) * focus));
currentShape._y = easeInOutQuad(currentShape.switchFrame, currentShape.switchY1, currentShape.switchY2 - currentShape.switchY1, currentShape.switchEnd);
} else {
allowPlace = true;
currentShape._alpha = currentShape._alpha + (((100 - currentShape._alpha) * 0.5) * focus);
currentShape._xscale = (currentShape._yscale = currentShape._yscale + (((100 - currentShape._xscale) * 0.5) * focus));
currentShape._y = currentShape.switchY2;
}
nextShape._y = (nextShape.switchY1 = (nextShape.switchY2 = currentShape._y));
if (allowPlace && (dropPressed)) {
placeShape(funnel.pos);
}
var allowRotate = (currentShape.rotateFrame >= (currentShape.rotateEnd - 0.01));
if (allowRotate && (zPressed)) {
currentShape.rotateFrame = 0;
currentShape.rotateEnd = 5;
currentShape.rotStart = currentShape.rotGoal;
currentShape.rotGoal = currentShape.rotGoal - 90;
updateColors();
fxRotate.start();
allowRotate = false;
} else if (allowRotate && (xPressed)) {
currentShape.rotateFrame = 0;
currentShape.rotateEnd = 5;
currentShape.rotStart = currentShape.rotGoal;
currentShape.rotGoal = currentShape.rotGoal + 90;
updateColors();
fxRotate.start();
allowRotate = false;
} else if (allowPlace && (cPressed)) {
funnel.pos = funnel.pos * -1;
currentShape.switchFrame = 0;
if (focus >= 0.6) {
var dur = (20 - (speed * 2));
if (dur < 5) {
dur = 5;
}
} else {
dur = 2;
}
currentShape.switchEnd = dur;
currentShape.switchY1 = currentShape._y;
currentShape.switchY2 = (gridHeight * sqrSize) - (((gridHeight * sqrSize) + (sqrSize * 2)) * funnel.pos);
allowPlace = false;
}
if (!allowRotate) {
currentShape.rotateFrame = currentShape.rotateFrame + Math.pow(focus, 1.5);
currentShape._rotation = easeInOutQuad(currentShape.rotateFrame, currentShape.rotStart, currentShape.rotGoal - currentShape.rotStart, currentShape.rotateEnd);
} else {
currentShape._rotation = currentShape.rotGoal;
}
currentShape._x = currentShape._x + ((rightPressed ? (sqrSize / 2) : ((((focus < 0.6) && (!allowRotate)) ? 0.1 : (speed)))) * focus);
if (((focus < 0.6) && (allowPlace)) && (gameSpeed == 1)) {
var results = findOrder(currentShape, funnel.pos);
var withinBounds = true;
var i = 0;
while (i < results.order.length) {
var x = Math.round(results.order[i].x / sqrSize);
if ((x < 0) || (x > (gridArr.length - 1))) {
withinBounds = false;
break;
}
i++;
}
if (withinBounds) {
var tempArr = [];
var x = 0;
while (x < gridArr.length) {
tempArr[x] = [];
var y = 0;
while (y < gridArr[x].length) {
tempArr[x][y] = gridArr[x][y];
y++;
}
x++;
}
var i = 0;
while (i < results.order.length) {
if (results.order[i].obj.hint == undefined) {
var clip = particles.createEmptyMovieClip("hint" + particles.depth, particles.depth++);
clip._alpha = 40;
results.order[i].obj.hint = clip;
} else {
var clip = results.order[i].obj.hint;
}
drawSquare(clip, results.order[i].obj.clr, 0);
var x = Math.round(results.order[i].x / sqrSize);
var y = Math.round(results.order[i].y / sqrSize);
var goal = ((funnel.pos == 1) ? (gridHeight) : (gridHeight - 1));
do {
y = y + funnel.pos;
} while (((tempArr[x][y] == -1) || (tempArr[x][y] == undefined)) && (y != goal));
y = y - funnel.pos;
tempArr[x][y] = "!";
clip._x = x * sqrSize;
clip._y = y * sqrSize;
clip.src = results.order[i].obj;
clip.onEnterFrame = function () {
if (((focus >= 0.6) || (this.src == undefined)) || (!allowPlace)) {
delete this.src.hint;
removeMovieClip(this);
}
};
i++;
}
}
}
} else {
if ((nextShape.switchFrame + focus) < nextShape.switchEnd) {
nextShape.switchFrame = nextShape.switchFrame + focus;
allowPlace = false;
nextShape._alpha = nextShape._alpha + (((30 - nextShape._alpha) * 0.5) * focus);
nextShape._xscale = (nextShape._yscale = nextShape._yscale + (((150 - nextShape._xscale) * 0.5) * focus));
nextShape._y = easeInOutQuad(nextShape.switchFrame, nextShape.switchY1, nextShape.switchY2 - nextShape.switchY1, nextShape.switchEnd);
} else {
allowPlace = true;
nextShape._alpha = nextShape._alpha + (((100 - nextShape._alpha) * 0.5) * focus);
nextShape._xscale = (nextShape._yscale = nextShape._yscale + (((100 - nextShape._xscale) * 0.5) * focus));
nextShape._y = nextShape.switchY2;
}
var allowRotate = (nextShape.rotateFrame >= (nextShape.rotateEnd - 0.01));
if (allowRotate && (zPressed)) {
nextShape.rotateFrame = 0;
nextShape.rotateEnd = 5;
nextShape.rotStart = nextShape.rotGoal;
nextShape.rotGoal = nextShape.rotGoal - 90;
updateColors();
fxRotate.start();
allowRotate = false;
} else if (allowRotate && (xPressed)) {
nextShape.rotateFrame = 0;
nextShape.rotateEnd = 5;
nextShape.rotStart = nextShape.rotGoal;
nextShape.rotGoal = nextShape.rotGoal + 90;
updateColors();
fxRotate.start();
allowRotate = false;
} else if (allowPlace && (cPressed)) {
funnel.pos = funnel.pos * -1;
nextShape.switchFrame = 0;
var dur = (20 - (speed * 2));
if (dur < 5) {
dur = 5;
}
nextShape.switchEnd = dur;
nextShape.switchY1 = nextShape._y;
nextShape.switchY2 = (gridHeight * sqrSize) - (((gridHeight * sqrSize) + (sqrSize * 2)) * funnel.pos);
}
if (!allowRotate) {
nextShape.rotateFrame = nextShape.rotateFrame + Math.pow(focus, 1.5);
nextShape._rotation = easeInOutQuad(nextShape.rotateFrame, nextShape.rotStart, nextShape.rotGoal - nextShape.rotStart, nextShape.rotateEnd);
} else {
nextShape._rotation = nextShape.rotGoal;
}
}
var focusGoal;
if ((curFocus > 0) && (spacePressed)) {
focusGoal = 0.1;
curFocus = curFocus - (allowRotate ? 0.5 : 0.2);
if (focusGoal != focusGoalPrev) {
fxFocusEnter.start();
addFocusHue();
}
} else {
focusGoal = 1;
if (focusGoal != focusGoalPrev) {
fxFocusExit.start();
removeFocusHue();
}
}
focusGoalPrev = focusGoal;
focus = focus + ((focusGoal - focus) * 0.4);
var i = 0;
while (i < squares.xPos.length) {
var x = squares.xPos[i];
var yGap = 0;
var y = (gridHeight - 1);
while (y >= 0) {
if (gridArr[x][y] == -1) {
yGap++;
} else if ((gridArr[x][y] != -1) && (yGap > 0)) {
gridArr[x][y + yGap] = gridArr[x][y];
gridArr[x][y] = -1;
moveSquare(gridArr[x][y + yGap], x, y + yGap);
}
y--;
}
var yGap = 0;
var y = gridHeight;
while (y < (gridHeight * 2)) {
if (gridArr[x][y] == -1) {
yGap++;
} else if ((gridArr[x][y] != -1) && (yGap > 0)) {
gridArr[x][y - yGap] = gridArr[x][y];
gridArr[x][y] = -1;
moveSquare(gridArr[x][y - yGap], x, y - yGap);
}
y++;
}
i++;
}
squares.xPos = [];
var i = 0;
while (i < squares.toRemove.length) {
if (squares.toRemove[i]._alpha == 100) {
explodeSquare(squares.toRemove[i]);
}
removeMovieClip(squares.toRemove[i]);
squares.toRemove.splice(i, 1);
i++;
}
if (currentShape._x > (sqrSize * (gridWidth + 1))) {
loseGame();
}
var multiplier = (squares.multi.length * squares.combo);
var i = 0;
while (i < squares.multi.length) {
var calcScore = squares.multi[i].calcScore;
var calcTxt = calcScore;
calcScore = calcScore * multiplier;
if ((squares.multi.length * squares.combo) > 1) {
calcTxt = (multiplier + " x ") + calcTxt;
}
addScore(calcScore, calcTxt, squares.combo, squares.multi[i].x, squares.multi[i].y);
i++;
}
if ((gametype == "dash") && (hud.score >= 5000)) {
loseGame();
}
squares.multi = [];
if (replay) {
var toUse = ((gametype == "timed") ? ((180 * framerate) - frame) : (frame));
var per = roundTo((toUse / replayEnd) * 100, 3);
if (per < 100) {
hud.time = framesToTime(frame);
hud.replayMC.percent = per + "%";
} else {
hud.time = hud.replayMC.totalTime;
hud.replayMC.percent = "100%";
}
hud.replayMC.percentBG = hud.replayMC.percent;
} else {
hud.time = framesToTime(frame);
}
hud.timeBG = hud.time;
if (tutorial) {
tutorialFunct();
}
if (gametype == "timed") {
frame--;
if (frame == 0) {
loseGame();
}
} else {
frame++;
}
}
function explodeSquare(src, offX, offY) {
var parts;
if (gameSpeed == 1) {
parts = 2;
} else if (gameSpeed <= 4) {
parts = 1;
} else {
parts = 0;
}
var x = 0;
while (x < parts) {
var y = 0;
while (y < parts) {
var clip = particles.createEmptyMovieClip("part" + particles.depth, particles.depth++);
drawSquare(clip, src.clr, 0, true);
clip._x = (src._x + ((sqrSize / parts) * x)) + offX;
clip._y = (src._y + ((sqrSize / parts) * y)) + offY;
clip._width = (clip._height = sqrSize / parts);
clip.xspeed = (Math.random() * 2) - 1;
clip.yspeed = (Math.random() * 2) - 1;
clip.fade = (Math.random() * 3) + 3;
clip.onEnterFrame = function () {
if (!paused) {
var i = 0;
while (i < gameSpeed) {
this._x = this._x + (this.xspeed * focus);
this._y = this._y + (this.yspeed * focus);
this._alpha = this._alpha - (this.fade * focus);
if (this._alpha <= 0) {
removeMovieClip(this);
}
i++;
}
}
};
y++;
}
x++;
}
}
function updateColors() {
var toUse = ((currentShape != undefined) ? (currentShape) : (nextShape));
for (var i in toUse) {
if (typeof(toUse[i]) == "movieclip") {
drawSquare(toUse[i], toUse[i].clr, toUse.rotGoal % 360);
}
}
}
function roundTo(num, digits) {
if (digits <= 0) {
return(Math.round(num));
}
var tenToPower = Math.pow(10, digits);
var cropped = String(Math.round(num * tenToPower) / tenToPower);
if (cropped.indexOf(".") == -1) {
cropped = cropped + ".0";
}
var halves = cropped.split(".");
var zerosNeeded = (digits - halves[1].length);
var i = 1;
while (i <= zerosNeeded) {
cropped = cropped + "0";
i++;
}
return(cropped);
}
function framesToTime(frames) {
var seconds = Math.floor(frames / framerate);
var minutes = Math.floor(seconds / 60);
if (minutes < 10) {
minutes = "0" + minutes;
}
var hours = Math.floor(minutes / 60);
seconds = seconds % 60;
if (seconds < 10) {
seconds = "0" + seconds;
}
return((((hours + ":") + minutes) + ":") + seconds);
}
function tutorialFunct() {
if (frame < tutorialText[tutIndex + 1].frame) {
hud.tutorialMC.tutText = tutorialText[tutIndex].txt.substr(0, frame - tutorialText[tutIndex].frame);
} else {
tutIndex++;
}
}
function restartReplay() {
newGame(gameStr);
}
function pauseReplay() {
paused = true;
}
function playReplay(speed) {
paused = false;
gameSpeed = speed;
}
function rgbToHex(r, g, b) {
return(((r << 16) | (g << 8)) | b);
}
function hexToRGB(hex) {
var red = (hex >> 16);
var grnBlu = (hex - (red << 16));
var grn = (grnBlu >> 8);
var blu = (grnBlu - (grn << 8));
return({r:red, g:grn, b:blu});
}
function addFocusHue() {
focusHue.onEnterFrame = function () {
this._alpha = this._alpha + 5;
if (this._alpha > 20) {
delete this.onEnterFrame;
}
};
}
function removeFocusHue() {
focusHue.onEnterFrame = function () {
this._alpha = this._alpha - 5;
if (this._alpha <= 0) {
delete this.onEnterFrame;
}
};
}
function loseGame() {
trace(recordStr);
delete funnel.onEnterFrame;
Key.removeListener(pauseWatch);
var count = 0;
focus = 1;
for (var i in currentShape) {
if (typeof(currentShape[i]) == "movieclip") {
explodeSquare(currentShape[i], currentShape._x, currentShape._y);
}
}
removeMovieClip(currentShape);
for (var i in nextShape) {
if (typeof(nextShape[i]) == "movieclip") {
explodeSquare(nextShape[i], nextShape._x, nextShape._y);
}
}
removeMovieClip(nextShape);
grid.circle0.goal = 0;
grid.circle1.goal = 0;
for (var i in squares) {
if (typeof(squares[i]) == "movieclip") {
count++;
squares[i].delay = count * 3;
squares[i].onEnterFrame = function () {
if (!paused) {
this.delay--;
if (this.delay < 0) {
explodeSquare(this);
removeMovieClip(this);
}
}
};
}
}
addScore(0, "Game Over", 1, gridWidth / 2, gridHeight);
if (!replay) {
hud.highScore._visible = true;
if (toSave.outOfDate) {
hud.highScore.gotoAndStop(5);
} else if ((((gametype == "endurance") && (hud.score == 0)) || ((gametype == "timed") && (frame > 0))) || ((gametype == "dash") && (hud.score < 5000))) {
hud.highScore.gotoAndStop(6);
} else {
hud.highScore.gotoAndStop(1);
loadHighScores(gametype);
}
}
}
function quitToMenu() {
delete gameStr;
Key.removeListener(pauseWatch);
for (var i in _root) {
if ((i != "toSave") && (i != "bg")) {
removeMovieClip(_root[i]);
delete _root[i];
}
}
prevFrame();
}
initialize();
Symbol 11 MovieClip [FUIComponentSymbol] Frame 1
#initclip 1
function FUIComponentClass() {
this.init();
}
FUIComponentClass.prototype = new MovieClip();
FUIComponentClass.prototype.init = function () {
this.enable = true;
this.focused = false;
this.useHandCursor = false;
this._accImpl = new Object();
this._accImpl.stub = true;
this.styleTable = new Array();
if (_global.globalStyleFormat == undefined) {
_global.globalStyleFormat = new FStyleFormat();
globalStyleFormat.isGlobal = true;
_global._focusControl = new Object();
_global._focusControl.onSetFocus = function (oldFocus, newFocus) {
oldFocus.myOnKillFocus();
newFocus.myOnSetFocus();
};
Selection.addListener(_global._focusControl);
}
if (this._name != undefined) {
this._focusrect = false;
this.tabEnabled = true;
this.focusEnabled = true;
this.tabChildren = false;
this.tabFocused = true;
if (this.hostStyle == undefined) {
globalStyleFormat.addListener(this);
} else {
this.styleTable = this.hostStyle;
}
this.deadPreview._visible = false;
this.deadPreview._width = (this.deadPreview._height = 1);
this.methodTable = new Object();
this.keyListener = new Object();
this.keyListener.controller = this;
this.keyListener.onKeyDown = function () {
this.controller.myOnKeyDown();
};
this.keyListener.onKeyUp = function () {
this.controller.myOnKeyUp();
};
for (var i in this.styleFormat_prm) {
this.setStyleProperty(i, this.styleFormat_prm[i]);
}
}
};
FUIComponentClass.prototype.setEnabled = function (enabledFlag) {
this.enable = ((arguments.length > 0) ? (enabledFlag) : true);
this.tabEnabled = (this.focusEnabled = enabledFlag);
if ((!this.enable) && (this.focused)) {
Selection.setFocus(undefined);
}
};
FUIComponentClass.prototype.getEnabled = function () {
return(this.enable);
};
FUIComponentClass.prototype.setSize = function (w, h) {
this.width = w;
this.height = h;
this.focusRect.removeMovieClip();
};
FUIComponentClass.prototype.setChangeHandler = function (chng, obj) {
this.handlerObj = ((obj == undefined) ? (this._parent) : (obj));
this.changeHandler = chng;
};
FUIComponentClass.prototype.invalidate = function (methodName) {
this.methodTable[methodName] = true;
this.onEnterFrame = this.cleanUI;
};
FUIComponentClass.prototype.cleanUI = function () {
if (this.methodTable.setSize) {
this.setSize(this.width, this.height);
} else {
this.cleanUINotSize();
}
this.methodTable = new Object();
delete this.onEnterFrame;
};
FUIComponentClass.prototype.cleanUINotSize = function () {
for (var funct in this.methodTable) {
this[funct]();
}
};
FUIComponentClass.prototype.drawRect = function (x, y, w, h) {
var inner = this.styleTable.focusRectInner.value;
var outer = this.styleTable.focusRectOuter.value;
if (inner == undefined) {
inner = 16777215 /* 0xFFFFFF */;
}
if (outer == undefined) {
outer = 0;
}
this.createEmptyMovieClip("focusRect", 1000);
this.focusRect.controller = this;
this.focusRect.lineStyle(1, outer);
this.focusRect.moveTo(x, y);
this.focusRect.lineTo(x + w, y);
this.focusRect.lineTo(x + w, y + h);
this.focusRect.lineTo(x, y + h);
this.focusRect.lineTo(x, y);
this.focusRect.lineStyle(1, inner);
this.focusRect.moveTo(x + 1, y + 1);
this.focusRect.lineTo((x + w) - 1, y + 1);
this.focusRect.lineTo((x + w) - 1, (y + h) - 1);
this.focusRect.lineTo(x + 1, (y + h) - 1);
this.focusRect.lineTo(x + 1, y + 1);
};
FUIComponentClass.prototype.pressFocus = function () {
this.tabFocused = false;
this.focusRect.removeMovieClip();
Selection.setFocus(this);
};
FUIComponentClass.prototype.drawFocusRect = function () {
this.drawRect(-2, -2, this.width + 4, this.height + 4);
};
FUIComponentClass.prototype.myOnSetFocus = function () {
this.focused = true;
Key.addListener(this.keyListener);
if (this.tabFocused) {
this.drawFocusRect();
}
};
FUIComponentClass.prototype.myOnKillFocus = function () {
this.tabFocused = true;
this.focused = false;
this.focusRect.removeMovieClip();
Key.removeListener(this.keyListener);
};
FUIComponentClass.prototype.executeCallBack = function () {
this.handlerObj[this.changeHandler](this);
};
FUIComponentClass.prototype.updateStyleProperty = function (styleFormat, propName) {
this.setStyleProperty(propName, styleFormat[propName], styleFormat.isGlobal);
};
FUIComponentClass.prototype.setStyleProperty = function (propName, value, isGlobal) {
if (value == "") {
return(undefined);
}
var tmpValue = parseInt(value);
if (!isNaN(tmpValue)) {
value = tmpValue;
}
var global = ((arguments.length > 2) ? (isGlobal) : false);
if (this.styleTable[propName] == undefined) {
this.styleTable[propName] = new Object();
this.styleTable[propName].useGlobal = true;
}
if (this.styleTable[propName].useGlobal || (!global)) {
this.styleTable[propName].value = value;
if (this.setCustomStyleProperty(propName, value)) {
} else if (propName == "embedFonts") {
this.invalidate("setSize");
} else if (propName.subString(0, 4) == "text") {
if (this.textStyle == undefined) {
this.textStyle = new TextFormat();
}
var textProp = propName.subString(4, propName.length);
this.textStyle[textProp] = value;
this.invalidate("setSize");
} else {
for (var j in this.styleTable[propName].coloredMCs) {
var myColor = new Color(this.styleTable[propName].coloredMCs[j]);
if (this.styleTable[propName].value == undefined) {
var myTObj = {ra:"100", rb:"0", ga:"100", gb:"0", ba:"100", bb:"0", aa:"100", ab:"0"};
myColor.setTransform(myTObj);
} else {
myColor.setRGB(value);
}
}
}
this.styleTable[propName].useGlobal = global;
}
};
FUIComponentClass.prototype.registerSkinElement = function (skinMCRef, propName) {
if (this.styleTable[propName] == undefined) {
this.styleTable[propName] = new Object();
this.styleTable[propName].useGlobal = true;
}
if (this.styleTable[propName].coloredMCs == undefined) {
this.styleTable[propName].coloredMCs = new Object();
}
this.styleTable[propName].coloredMCs[skinMCRef] = skinMCRef;
if (this.styleTable[propName].value != undefined) {
var myColor = new Color(skinMCRef);
myColor.setRGB(this.styleTable[propName].value);
}
};
_global.FStyleFormat = function () {
this.nonStyles = {listeners:true, isGlobal:true, isAStyle:true, addListener:true, removeListener:true, nonStyles:true, applyChanges:true};
this.listeners = new Object();
this.isGlobal = false;
if (arguments.length > 0) {
for (var i in arguments[0]) {
this[i] = arguments[0][i];
}
}
};
_global.FStyleFormat.prototype = new Object();
FStyleFormat.prototype.addListener = function () {
var arg = 0;
while (arg < arguments.length) {
var mcRef = arguments[arg];
this.listeners[arguments[arg]] = mcRef;
for (var i in this) {
if (this.isAStyle(i)) {
mcRef.updateStyleProperty(this, i.toString());
}
}
arg++;
}
};
FStyleFormat.prototype.removeListener = function (component) {
this.listeners[component] = undefined;
for (var prop in this) {
if (this.isAStyle(prop)) {
if (component.styleTable[prop].useGlobal == this.isGlobal) {
component.styleTable[prop].useGlobal = true;
var value = (this.isGlobal ? undefined : (globalStyleFormat[prop]));
component.setStyleProperty(prop, value, true);
}
}
}
};
FStyleFormat.prototype.applyChanges = function () {
var count = 0;
for (var i in this.listeners) {
var component = this.listeners[i];
if (arguments.length > 0) {
var j = 0;
while (j < arguments.length) {
if (this.isAStyle(arguments[j])) {
component.updateStyleProperty(this, arguments[j]);
}
j++;
}
} else {
for (var j in this) {
if (this.isAStyle(j)) {
component.updateStyleProperty(this, j.toString());
}
}
}
}
};
FStyleFormat.prototype.isAStyle = function (name) {
return((this.nonStyles[name] ? false : true));
};
#endinitclip
Symbol 24 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 34 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 43 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "foregroundDisabled");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 44 MovieClip [UpArrow] Frame 1
stop();
Symbol 44 MovieClip [UpArrow] Frame 2
stop();
Symbol 44 MovieClip [UpArrow] Frame 3
stop();
Symbol 51 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 58 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 63 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(highlight3D_mc, "highlight3D");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
Symbol 64 MovieClip [ScrollThumb] Frame 1
stop();
Symbol 72 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 80 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "arrow");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 88 MovieClip Frame 1
var component = _parent._parent;
component.registerSkinElement(arrow_mc, "foregroundDisabled");
component.registerSkinElement(face_mc, "face");
component.registerSkinElement(shadow_mc, "shadow");
component.registerSkinElement(darkshadow_mc, "darkshadow");
component.registerSkinElement(highlight_mc, "highlight");
component.registerSkinElement(highlight3D_mc, "highlight3D");
Symbol 89 MovieClip [DownArrow] Frame 1
stop();
Symbol 89 MovieClip [DownArrow] Frame 2
stop();
Symbol 89 MovieClip [DownArrow] Frame 3
stop();
Symbol 94 MovieClip Frame 1
var component = _parent;
component.registerSkinElement(track_mc, "scrollTrack");
Symbol 95 MovieClip [FScrollBarSymbol] Frame 1
#initclip 2
FScrollBarClass = function () {
if (this._height == 4) {
return(undefined);
}
this.init();
this.minPos = (this.maxPos = (this.pageSize = (this.largeScroll = 0)));
this.smallScroll = 1;
this.width = (this.horizontal ? (this._width) : (this._height));
this._xscale = (this._yscale = 100);
this.setScrollPosition(0);
this.tabEnabled = false;
if (this._targetInstanceName.length > 0) {
this.setScrollTarget(this._parent[this._targetInstanceName]);
}
this.tabChildren = false;
this.setSize(this.width);
};
FScrollBarClass.prototype = new FUIComponentClass();
FScrollBarClass.prototype.setHorizontal = function (flag) {
if (this.horizontal && (!flag)) {
this._xscale = 100;
this._rotation = 0;
} else if (flag && (!this.horizontal)) {
this._xscale = -100;
this._rotation = -90;
}
this.horizontal = flag;
};
FScrollBarClass.prototype.setScrollProperties = function (pSize, mnPos, mxPos) {
if (!this.enable) {
return(undefined);
}
this.pageSize = pSize;
this.minPos = Math.max(mnPos, 0);
this.maxPos = Math.max(mxPos, 0);
this.scrollPosition = Math.max(this.minPos, this.scrollPosition);
this.scrollPosition = Math.min(this.maxPos, this.scrollPosition);
if ((this.maxPos - this.minPos) <= 0) {
this.scrollThumb_mc.removeMovieClip();
this.upArrow_mc.gotoAndStop(3);
this.downArrow_mc.gotoAndStop(3);
this.downArrow_mc.onPress = (this.downArrow_mc.onRelease = (this.downArrow_mc.onDragOut = null));
this.upArrow_mc.onPress = (this.upArrow_mc.onRelease = (this.upArrow_mc.onDragOut = null));
this.scrollTrack_mc.onPress = (this.scrollTrack_mc.onRelease = null);
this.scrollTrack_mc.onDragOut = (this.scrollTrack_mc.onRollOut = null);
this.scrollTrack_mc.useHandCursor = false;
} else {
var tmp = this.getScrollPosition();
this.upArrow_mc.gotoAndStop(1);
this.downArrow_mc.gotoAndStop(1);
this.upArrow_mc.onPress = (this.upArrow_mc.onDragOver = this.startUpScroller);
this.upArrow_mc.onRelease = (this.upArrow_mc.onDragOut = this.stopScrolling);
this.downArrow_mc.onPress = (this.downArrow_mc.onDragOver = this.startDownScroller);
this.downArrow_mc.onRelease = (this.downArrow_mc.onDragOut = this.stopScrolling);
this.scrollTrack_mc.onPress = (this.scrollTrack_mc.onDragOver = this.startTrackScroller);
this.scrollTrack_mc.onRelease = this.stopScrolling;
this.scrollTrack_mc.onDragOut = this.stopScrolling;
this.scrollTrack_mc.onRollOut = this.stopScrolling;
this.scrollTrack_mc.useHandCursor = false;
this.attachMovie("ScrollThumb", "scrollThumb_mc", 3);
this.scrollThumb_mc._x = 0;
this.scrollThumb_mc._y = this.upArrow_mc._height;
this.scrollThumb_mc.onPress = this.startDragThumb;
this.scrollThumb_mc.controller = this;
this.scrollThumb_mc.onRelease = (this.scrollThumb_mc.onReleaseOutside = this.stopDragThumb);
this.scrollThumb_mc.useHandCursor = false;
this.thumbHeight = (this.pageSize / ((this.maxPos - this.minPos) + this.pageSize)) * this.trackSize;
this.thumbMid_mc = this.scrollThumb_mc.mc_sliderMid;
this.thumbTop_mc = this.scrollThumb_mc.mc_sliderTop;
this.thumbBot_mc = this.scrollThumb_mc.mc_sliderBot;
this.thumbHeight = Math.max(this.thumbHeight, 6);
this.midHeight = (this.thumbHeight - this.thumbTop_mc._height) - this.thumbBot_mc._height;
this.thumbMid_mc._yScale = (this.midHeight * 100) / this.thumbMid_mc._height;
this.thumbMid_mc._y = this.thumbTop_mc._height;
this.thumbBot_mc._y = this.thumbTop_mc._height + this.midHeight;
this.scrollTop = this.scrollThumb_mc._y;
this.trackHeight = this.trackSize - this.thumbHeight;
this.scrollBot = this.trackHeight + this.scrollTop;
tmp = Math.min(tmp, this.maxPos);
this.setScrollPosition(Math.max(tmp, this.minPos));
}
};
FScrollBarClass.prototype.getScrollPosition = function () {
return(this.scrollPosition);
};
FScrollBarClass.prototype.setScrollPosition = function (pos) {
this.scrollPosition = pos;
if (this.scrollThumb_mc != undefined) {
pos = Math.min(pos, this.maxPos);
pos = Math.max(pos, this.minPos);
}
this.scrollThumb_mc._y = (((pos - this.minPos) * this.trackHeight) / (this.maxPos - this.minPos)) + this.scrollTop;
this.executeCallBack();
};
FScrollBarClass.prototype.setLargeScroll = function (lScroll) {
this.largeScroll = lScroll;
};
FScrollBarClass.prototype.setSmallScroll = function (sScroll) {
this.smallScroll = sScroll;
};
FScrollBarClass.prototype.setEnabled = function (enabledFlag) {
var wasEnabled = this.enable;
if (enabledFlag && (!wasEnabled)) {
this.enable = enabledFlag;
if (this.textField != undefined) {
this.setScrollTarget(this.textField);
} else {
this.setScrollProperties(this.pageSize, this.cachedMinPos, this.cachedMaxPos);
this.setScrollPosition(this.cachedPos);
}
this.clickFilter = undefined;
} else if ((!enabledFlag) && (wasEnabled)) {
this.textField.removeListener(this);
this.cachedPos = this.getScrollPosition();
this.cachedMinPos = this.minPos;
this.cachedMaxPos = this.maxPos;
if (this.clickFilter == undefined) {
this.setScrollProperties(this.pageSize, 0, 0);
} else {
this.clickFilter = true;
}
this.enable = enabledFlag;
}
};
FScrollBarClass.prototype.setSize = function (hgt) {
if (this._height == 1) {
return(undefined);
}
this.width = hgt;
this.scrollTrack_mc._yscale = 100;
this.scrollTrack_mc._yscale = (100 * this.width) / this.scrollTrack_mc._height;
if (this.upArrow_mc == undefined) {
this.attachMovie("UpArrow", "upArrow_mc", 1);
this.attachMovie("DownArrow", "downArrow_mc", 2);
this.downArrow_mc.controller = (this.upArrow_mc.controller = this);
this.upArrow_mc.useHandCursor = (this.downArrow_mc.useHandCursor = false);
this.upArrow_mc._x = (this.upArrow_mc._y = 0);
this.downArrow_mc._x = 0;
}
this.scrollTrack_mc.controller = this;
this.downArrow_mc._y = this.width - this.downArrow_mc._height;
this.trackSize = this.width - (2 * this.downArrow_mc._height);
if (this.textField != undefined) {
this.onTextChanged();
} else {
this.setScrollProperties(this.pageSize, this.minPos, this.maxPos);
}
};
FScrollBarClass.prototype.scrollIt = function (inc, mode) {
var delt = this.smallScroll;
if (inc != "one") {
delt = ((this.largeScroll == 0) ? (this.pageSize) : (this.largeScroll));
}
var newPos = (this.getScrollPosition() + (mode * delt));
if (newPos > this.maxPos) {
newPos = this.maxPos;
} else if (newPos < this.minPos) {
newPos = this.minPos;
}
this.setScrollPosition(newPos);
};
FScrollBarClass.prototype.startDragThumb = function () {
this.lastY = this._ymouse;
this.onMouseMove = this.controller.dragThumb;
};
FScrollBarClass.prototype.dragThumb = function () {
this.scrollMove = this._ymouse - this.lastY;
this.scrollMove = this.scrollMove + this._y;
if (this.scrollMove < this.controller.scrollTop) {
this.scrollMove = this.controller.scrollTop;
} else if (this.scrollMove > this.controller.scrollBot) {
this.scrollMove = this.controller.scrollBot;
}
this._y = this.scrollMove;
var c = this.controller;
c.scrollPosition = Math.round(((c.maxPos - c.minPos) * (this._y - c.scrollTop)) / c.trackHeight) + c.minPos;
this.controller.isScrolling = true;
updateAfterEvent();
this.controller.executeCallBack();
};
FScrollBarClass.prototype.stopDragThumb = function () {
this.controller.isScrolling = false;
this.onMouseMove = null;
};
FScrollBarClass.prototype.startTrackScroller = function () {
this.controller.trackScroller();
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "page", -1);
};
FScrollBarClass.prototype.scrollInterval = function (inc, mode) {
clearInterval(this.scrolling);
if (inc == "page") {
this.trackScroller();
} else {
this.scrollIt(inc, mode);
}
this.scrolling = setInterval(this, "scrollInterval", 35, inc, mode);
};
FScrollBarClass.prototype.trackScroller = function () {
if ((this.scrollThumb_mc._y + this.thumbHeight) < this._ymouse) {
this.scrollIt("page", 1);
} else if (this.scrollThumb_mc._y > this._ymouse) {
this.scrollIt("page", -1);
}
};
FScrollBarClass.prototype.stopScrolling = function () {
this.controller.downArrow_mc.gotoAndStop(1);
this.controller.upArrow_mc.gotoAndStop(1);
clearInterval(this.controller.scrolling);
};
FScrollBarClass.prototype.startUpScroller = function () {
this.controller.upArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one", -1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", -1);
};
FScrollBarClass.prototype.startDownScroller = function () {
this.controller.downArrow_mc.gotoAndStop(2);
this.controller.scrollIt("one", 1);
this.controller.scrolling = setInterval(this.controller, "scrollInterval", 500, "one", 1);
};
FScrollBarClass.prototype.setScrollTarget = function (tF) {
if (tF == undefined) {
this.textField.removeListener(this);
delete this.textField[(this.horizontal ? "hScroller" : "vScroller")];
if ((this.textField.hScroller != undefined) && (this.textField.vScroller != undefined)) {
this.textField.unwatch("text");
this.textField.unwatch("htmltext");
}
}
this.textField = undefined;
if (!(tF instanceof TextField)) {
return(undefined);
}
this.textField = tF;
this.textField[(this.horizontal ? "hScroller" : "vScroller")] = this;
this.onTextChanged();
this.onChanged = function () {
this.onTextChanged();
};
this.onScroller = function () {
if (!this.isScrolling) {
if (!this.horizontal) {
this.setScrollPosition(this.textField.scroll);
} else {
this.setScrollPosition(this.textField.hscroll);
}
}
};
this.textField.addListener(this);
this.textField.watch("text", this.callback);
this.textField.watch("htmlText", this.callback);
};
FScrollBarClass.prototype.callback = function (prop, oldVal, newVal) {
clearInterval(this.hScroller.synchScroll);
clearInterval(this.vScroller.synchScroll);
this.hScroller.synchScroll = setInterval(this.hScroller, "onTextChanged", 50);
this.vScroller.synchScroll = setInterval(this.vScroller, "onTextChanged", 50);
return(newVal);
};
FScrollBarClass.prototype.onTextChanged = function () {
if ((!this.enable) || (this.textField == undefined)) {
return(undefined);
}
clearInterval(this.synchScroll);
if (this.horizontal) {
var pos = this.textField.hscroll;
this.setScrollProperties(this.textField._width, 0, this.textField.maxhscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxhscroll));
} else {
var pos = this.textField.scroll;
var pageSize = (this.textField.bottomScroll - this.textField.scroll);
this.setScrollProperties(pageSize, 1, this.textField.maxscroll);
this.setScrollPosition(Math.min(pos, this.textField.maxscroll));
}
};
FScrollBarClass.prototype.executeCallBack = function () {
if (this.textField == undefined) {
super.executeCallBack();
} else if (this.horizontal) {
this.textField.hscroll = this.getScrollPosition();
} else {
this.textField.scroll = this.getScrollPosition();
}
};
Object.registerClass("FScrollBarSymbol", FScrollBarClass);
#endinitclip
Symbol 99 MovieClip [FBoundingBoxSymbol] Frame 1
var component = _parent;
component.registerSkinElement(boundingBox, "background");
stop();
Symbol 99 MovieClip [FBoundingBoxSymbol] Frame 2
component.registerSkinElement(boundingBox2, "backgroundDisabled");
stop();
Symbol 103 MovieClip [FScrollPaneSymbol] Frame 1
#initclip 3
function FScrollPaneClass() {
function boolToString(str) {
if (str == "false") {
return(false);
}
if (str == "true") {
return(true);
}
return(str);
}
this.init();
this.width = this._width;
this.height = this._height;
this._xscale = (this._yscale = 100);
this.contentWidth = (this.contentHeight = 0);
if (this.hScroll == undefined) {
this.hScroll = (this.vScroll = "auto");
this.dragContent = false;
}
this.offset = new Object();
this.vScroll = boolToString(this.vScroll);
this.hScroll = boolToString(this.hScroll);
this.attachMovie("FScrollBarSymbol", "hScrollBar_mc", 100, {hostStyle:this.styleTable});
this.hScrollBar_mc.setHorizontal(true);
this.hScrollBar_mc.setSmallScroll(5);
this.hScrollBar_mc.setChangeHandler("onScroll", this);
this.attachMovie("FScrollBarSymbol", "vScrollBar_mc", 99, {hostStyle:this.styleTable});
this.vScrollBar_mc.setSmallScroll(5);
this.vScrollBar_mc.setChangeHandler("onScroll", this);
this.setSize(this.width, this.height);
if (this.scrollContent != "") {
this.setScrollContent(this.scrollContent);
}
this.setDragContent(this.dragContent);
}
FScrollPaneClass.prototype = new FUIComponentClass();
Object.registerClass("FScrollPaneSymbol", FScrollPaneClass);
FScrollPaneClass.prototype.getScrollContent = function () {
return(this.content_mc);
};
FScrollPaneClass.prototype.getPaneWidth = function () {
return(this.width);
};
FScrollPaneClass.prototype.getPaneHeight = function () {
return(this.height);
};
FScrollPaneClass.prototype.getScrollPosition = function () {
var xPos = ((this.hScrollBar_mc == undefined) ? 0 : (this.hScrollBar_mc.getScrollPosition()));
var yPos = ((this.vScrollBar_mc == undefined) ? 0 : (this.vScrollBar_mc.getScrollPosition()));
return({x:xPos, y:yPos});
};
FScrollPaneClass.prototype.setScrollContent = function (target) {
this.offset.x = 0;
this.offset.y = 0;
if (this.content_mc != undefined) {
if (target != this.content_mc) {
this.content_mc._visible = false;
this.content_mc.removeMovieClip();
this.content_mc.unloadMovie();
}
}
if (typeof(target) == "string") {
this.attachMovie(target, "tmp_mc", 3);
this.content_mc = this.tmp_mc;
} else if (target == undefined) {
this.content_mc.unloadMovie();
} else {
this.content_mc = target;
}
this.localToGlobal(this.offset);
this.content_mc._parent.globalToLocal(this.offset);
this.content_mc._x = this.offset.x;
this.content_mc._y = this.offset.y;
var contentBounds = this.content_mc.getBounds(this);
this.offset.x = -contentBounds.xMin;
this.offset.y = -contentBounds.yMin;
this.localToGlobal(this.offset);
this.content_mc._parent.globalToLocal(this.offset);
this.content_mc._x = this.offset.x;
this.content_mc._y = this.offset.y;
this.contentWidth = this.content_mc._width;
this.contentHeight = this.content_mc._height;
this.content_mc.setMask(this.mask_mc);
this.setSize(this.width, this.height);
};
FScrollPaneClass.prototype.setSize = function (w, h) {
if (((arguments.length < 2) || (isNaN(w))) || (isNaN(h))) {
return(undefined);
}
super.setSize(w, h);
this.width = Math.max(w, 60);
this.height = Math.max(h, 60);
this.boundingBox_mc._xscale = 100;
this.boundingBox_mc._yscale = 100;
this.boundingBox_mc._width = this.width;
this.boundingBox_mc._height = this.height;
this.setHandV();
this.initScrollBars();
if (this.mask_mc == undefined) {
this.attachMovie("FBoundingBoxSymbol", "mask_mc", 3000);
}
this.mask_mc._xscale = 100;
this.mask_mc._yscale = 100;
this.mask_mc._width = this.hWidth;
this.mask_mc._height = this.vHeight;
this.mask_mc._alpha = 0;
};
FScrollPaneClass.prototype.setScrollPosition = function (x, y) {
x = Math.max(this.hScrollBar_mc.minPos, x);
x = Math.min(this.hScrollBar_mc.maxPos, x);
y = Math.max(this.vScrollBar_mc.minPos, y);
y = Math.min(this.vScrollBar_mc.maxPos, y);
this.hScrollBar_mc.setScrollPosition(x);
this.vScrollBar_mc.setScrollPosition(y);
};
FScrollPaneClass.prototype.refreshPane = function () {
this.setScrollContent(this.content_mc);
};
FScrollPaneClass.prototype.loadScrollContent = function (url, handler, location) {
this.content_mc.removeMovieClip();
this.content_mc.unloadMovie();
this.content_mc._visible = 0;
this.loadContent.duplicateMovieClip("loadTemp", 3);
this.dupeFlag = true;
this.contentLoaded = function () {
this.loadReady = false;
this.content_mc = this.loadTemp;
this.refreshPane();
this.executeCallBack();
};
this.setChangeHandler(handler, location);
this.loadTemp.loadMovie(url);
};
FScrollPaneClass.prototype.setHScroll = function (prop) {
this.hScroll = prop;
this.setSize(this.width, this.height);
};
FScrollPaneClass.prototype.setVScroll = function (prop) {
this.vScroll = prop;
this.setSize(this.width, this.height);
};
FScrollPaneClass.prototype.setDragContent = function (dragFlag) {
if (dragFlag) {
this.boundingBox_mc.useHandCursor = true;
this.boundingBox_mc.onPress = function () {
this._parent.startDragLoop();
};
this.boundingBox_mc.tabEnabled = false;
this.boundingBox_mc.onRelease = (this.boundingBox_mc.onReleaseOutside = function () {
this._parent.pressFocus();
this._parent.onMouseMove = null;
});
} else {
delete this.boundingBox_mc.onPress;
this.boundingBox_mc.useHandCursor = false;
}
};
FScrollPaneClass.prototype.setSmallScroll = function (x, y) {
this.hScrollBar_mc.setSmallScroll(x);
this.vScrollBar_mc.setSmallScroll(y);
};
FScrollPaneClass.prototype.setHandV = function () {
if ((((this.contentHeight - this.height) > 2) && (this.vScroll != false)) || (this.vScroll == true)) {
this.hWidth = this.width - this.vScrollBar_mc._width;
} else {
this.hWidth = this.width;
}
if ((((this.contentWidth - this.width) > 2) && (this.hScroll != false)) || (this.hScroll == true)) {
this.vHeight = this.height - this.hScrollBar_mc._height;
} else {
this.vHeight = this.height;
}
};
FScrollPaneClass.prototype.startDragLoop = function () {
this.tabFocused = false;
this.myOnSetFocus();
this.lastX = this._xmouse;
this.lastY = this._ymouse;
this.onMouseMove = function () {
this.scrollXMove = this.lastX - this._xmouse;
this.scrollYMove = this.lastY - this._ymouse;
this.scrollXMove = this.scrollXMove + this.hScrollBar_mc.getScrollPosition();
this.scrollYMove = this.scrollYMove + this.vScrollBar_mc.getScrollPosition();
this.setScrollPosition(this.scrollXMove, this.scrollYMove);
if ((this.scrollXMove < this.hScrollBar_mc.maxPos) && (this.scrollXMove > this.hScrollBar_mc.minPos)) {
this.lastX = this._xmouse;
}
if ((this.scrollYMove < this.vScrollBar_mc.maxPos) && (this.scrollYMove > this.vScrollBar_mc.minPos)) {
this.lastY = this._ymouse;
}
this.updateAfterEvent();
};
};
FScrollPaneClass.prototype.initScrollBars = function () {
this.hScrollBar_mc._y = this.height - this.hScrollBar_mc._height;
this.hScrollBar_mc.setSize(this.hWidth);
this.hScrollBar_mc.setScrollProperties(this.hWidth, 0, this.contentWidth - this.hWidth);
this.vScrollBar_mc._visible = ((this.hWidth == this.width) ? false : true);
this.vScrollBar_mc._x = this.width - this.vScrollBar_mc._width;
this.vScrollBar_mc.setSize(this.vHeight);
this.vScrollBar_mc.setScrollProperties(this.vHeight, 0, this.contentHeight - this.vHeight);
this.hScrollBar_mc._visible = ((this.vHeight == this.height) ? false : true);
};
FScrollPaneClass.prototype.onScroll = function (component) {
var pos = component.getScrollPosition();
var XorY = ((component._name == "hScrollBar_mc") ? "x" : "y");
if (component._name == "hScrollBar_mc") {
this.content_mc._x = (-pos) + this.offset.x;
} else {
this.content_mc._y = (-pos) + this.offset.y;
}
};
FScrollPaneClass.prototype.myOnKeyDown = function () {
var posX = this.hScrollBar_mc.getScrollPosition();
var posY = this.vScrollBar_mc.getScrollPosition();
if (this.hScrollBar_mc.maxPos > this.hScrollBar_mc.minPos) {
if (Key.isDown(37)) {
this.setScrollPosition(posX - 3, posY);
} else if (Key.isDown(39)) {
this.setScrollPosition(posX + 3, posY);
}
}
if (this.vScrollBar_mc.maxPos > this.vScrollBar_mc.minPos) {
if (Key.isDown(38)) {
this.setScrollPosition(posX, posY - 3);
} else if (Key.isDown(40)) {
this.setScrollPosition(posX, posY + 3);
} else if (Key.isDown(34)) {
this.setScrollPosition(posX, posY + this.vScrollBar_mc.pageSize);
} else if (Key.isDown(33)) {
this.setScrollPosition(posX, posY - this.vScrollBar_mc.pageSize);
}
}
};
#endinitclip
this.deadPreview._visible = false;
Instance of Symbol 95 MovieClip [FScrollBarSymbol] "scrollBarAsset" in Symbol 103 MovieClip [FScrollPaneSymbol] Frame 1
//component parameters
onClipEvent (initialize) {
_targetInstanceName = "";
horizontal = false;
}
Instance of Symbol 100 MovieClip "loadContent" in Symbol 103 MovieClip [FScrollPaneSymbol] Frame 1
onClipEvent (load) {
if (this._parent.loadReady) {
this._parent.contentLoaded();
delete this._parent.loadReady;
} else if (this._name != "loadContent") {
this._parent.loadReady = true;
}
}
Symbol 117 Button
on (release) {
_root.removeExtras();
gotoAndStop (4);
}
Symbol 121 Button
on (release) {
_root.removeExtras();
gotoAndStop (2);
}
Symbol 125 Button
on (release) {
_root.removeExtras();
_root.gameStr = _root.tutStr;
_root.tutorial = true;
_root.gametype = "endurance";
_root.nextFrame();
}
Symbol 142 Button
on (release) {
_root.loadHighScores("endurance");
}
Symbol 146 Button
on (release) {
_root.loadHighScores("timed");
}
Symbol 150 Button
on (release) {
_root.loadHighScores("dash");
}
Symbol 166 Button
on (rollOver) {
shield.veloc = 0;
shield.onEnterFrame = pulseIcon;
}
on (rollOut) {
delete shield.onEnterFrame;
shield._xscale = (shield._yscale = 100);
}
on (release) {
_root.gametype = "endurance";
_root.nextFrame();
}
Symbol 172 Button
on (rollOver) {
clock.veloc = 0;
clock.onEnterFrame = pulseIcon;
}
on (rollOut) {
delete clock.onEnterFrame;
clock._xscale = (clock._yscale = 100);
}
on (release) {
_root.gametype = "timed";
_root.nextFrame();
}
Symbol 177 Button
on (rollOver) {
shoe.veloc = 0;
shoe.onEnterFrame = pulseIcon;
}
on (rollOut) {
delete shoe.onEnterFrame;
shoe._xscale = (shoe._yscale = 100);
}
on (release) {
_root.gametype = "dash";
_root.nextFrame();
}
Symbol 184 MovieClip Frame 1
stop();
versionStatus.onRelease = function () {
getURL ("http://flash.isnan.net/gravitude/gravitude.zip");
};
Symbol 184 MovieClip Frame 2
function displayHighScores(scoreStr) {
loading._visible = false;
var scoreFormat = new TextFormat();
scoreFormat.font = "Eras";
scoreFormat.size = 12;
createEmptyMovieClip("scoreList", 0);
var scoreArr = scoreStr.split(newline);
var headers = ["#", "score", "name", "level", "spheres", "time", "replay"];
var gaps = [0, 20, 75, 250, 290, 330, 390, 450];
var wid = 450;
var hei = 20;
var i = 0;
while (i < scoreArr.length) {
if (scoreArr[i] != "") {
var detail = scoreArr[i].split(";");
var clip = scoreList.createEmptyMovieClip("record" + i, i);
clip._y = i * hei;
with (clip) {
beginFill(((i % 2) ? 16777215 : 13421772), 50);
lineTo(wid, 0);
lineTo(wid, hei);
lineTo(0, hei);
endFill();
lineStyle(1, 0, 20);
var j = 0;
while (j < gaps.length) {
moveTo(gaps[j], 0);
lineTo(gaps[j], hei);
j++;
}
}
var j = 0;
while (j < headers.length) {
var obj = clip.createEmptyMovieClip("label" + j, j);
if (j == 6) {
obj.content = detail[j];
}
obj.createTextField("label", 0, gaps[j], 0, gaps[j + 1] - gaps[j], hei);
var txt = obj.label;
txt.setNewTextFormat(scoreFormat);
if (j == 0) {
txt.text = i + 1;
} else if (j == 6) {
if (!_root.toSave.outOfDate) {
txt.text = "view";
obj.onRollOver = (obj.onDragOver = function () {
this.label.textColor = 16777215 /* 0xFFFFFF */;
});
obj.onRollOut = (obj.onDragOut = function () {
this.label.textColor = 0;
});
obj.onRelease = function () {
_root.gametype = gametype;
var loadReplay = new LoadVars();
loadReplay.load(((_root.toSave.replayDir + "replay") + this.content) + ".rep");
loadReplay.onLoad = function () {
_root.gameStr = unescape(this).split("=")[0];
_root.nextFrame();
};
onEnterFrame = function () {
var per = (loadReplay.getBytesLoaded() / loadReplay.getBytesTotal());
if (isNaN(per)) {
per = 0;
}
loadPercent = Math.round(per * 100) + "%";
if (per == 1) {
delete this.onEnterFrame;
}
};
nextFrame();
removeMovieClip(scoreList);
};
}
} else {
txt.text = detail[j];
}
txt.embedFonts = true;
txt.selectable = false;
j++;
}
} else {
scoreArr.splice(i, 1);
i--;
}
i++;
}
scorePane.setScrollContent(scoreList);
}
_root.loadHighScores("endurance");
Instance of Symbol 103 MovieClip [FScrollPaneSymbol] "scorePane" in Symbol 184 MovieClip Frame 2
//component parameters
onClipEvent (initialize) {
scrollContent = "";
hScroll = false;
vScroll = "auto";
dragContent = false;
}
Symbol 184 MovieClip Frame 4
function pulseIcon() {
this.veloc = this.veloc + ((80 - this._xscale) * 0.05);
this._xscale = (this._yscale = this._yscale + this.veloc);
}
Symbol 214 Button
on (rollOver) {
controlsText = "Restart";
}
on (rollOut) {
controlsText = "";
}
on (release) {
_root.restartReplay();
}
Symbol 218 Button
on (rollOver) {
controlsText = "Pause";
}
on (rollOut) {
controlsText = "";
}
on (release) {
_root.pauseReplay();
}
Symbol 222 Button
on (rollOver) {
controlsText = "Play";
}
on (rollOut) {
controlsText = "";
}
on (release) {
_root.playReplay(1);
}
Symbol 226 Button
on (rollOver) {
controlsText = "Play (4x)";
}
on (rollOut) {
controlsText = "";
}
on (release) {
_root.playReplay(4);
}
Symbol 230 Button
on (rollOver) {
controlsText = "Play (16x)";
}
on (rollOut) {
controlsText = "";
}
on (release) {
_root.playReplay(16);
}
Symbol 237 Button
on (release) {
_root.quitToMenu();
}
Symbol 243 MovieClip Frame 1
frames = 0;
timer = getTimer() + 1000;
onEnterFrame = function () {
frames++;
if (getTimer() > timer) {
fps = frames + " fps";
frames = 0;
timer = timer + 1000;
}
};
Symbol 253 Button
on (release, keyPress "<Enter>") {
if ((name.text != "") && (name.text != undefined)) {
_root.toSave.name = name.text;
_root.saveHighScore(name.text, _parent.score, _parent.level, _parent.spheres, ((_root.gametype == "timed") ? "3:00" : (_parent.time)), _root.recordStr, _root.gametype, sortNum);
nextFrame();
}
}
Symbol 261 Button
on (release) {
_root.newGame();
}
Symbol 263 Button
on (release) {
_root.newGame();
}
Symbol 265 MovieClip Frame 1
function transferScores(scoresStr) {
if (_root.gametype == "dash") {
var detail = _parent.time.split(":");
var hr = Number(detail[0]);
var min = Number(detail[1]);
var sec = Number(detail[2]);
sortNum = (((hr * 60) * 60) + (min * 60)) + sec;
} else {
sortNum = _parent.score;
}
var scoreArr = scoresStr.split(newline);
pos = 0;
var i = 0;
while (i < scoreArr.length) {
if (scoreArr[i] != "") {
var compare = Number(scoreArr[i].split(";")[0]);
if (((_root.gametype != "dash") && (sortNum > compare)) || ((_root.gametype == "dash") && (sortNum < compare))) {
break;
}
pos++;
}
i++;
}
if (pos < 50) {
gotoAndStop (2);
} else {
gotoAndStop (5);
}
}
stop();
Symbol 265 MovieClip Frame 2
rank = "rank #" + (pos + 1);
if (_root.toSave.name != undefined) {
name.text = _root.toSave.name;
}
Selection.setFocus("name");