Frame 1
function initAll() {
myLevel = new LevelClass(DEPTH_POPUP);
myGrid = new GridClass(DEPTH_GRID);
myLauncher = new LauncherClass(DEPTH_LAUNCHER);
myController = new MouseControllerClass();
myScore = new ScoreClass(mcScore);
myHST = new HighScoreTableClass("Handball_functions.aspx", "POST");
SoundClass.init();
snd_ballPop1 = new SoundClass("pop1.wav");
snd_ballPop2 = new SoundClass("pop2.wav");
snd_ballPop3 = new SoundClass("pop3.wav");
snd_ballPop4 = new SoundClass("pop4.wav");
snd_ballPop5 = new SoundClass("pop5.wav");
snd_ballPopArr = [snd_ballPop1, snd_ballPop2, snd_ballPop3, snd_ballPop4, snd_ballPop5];
snd_ballThrow = new SoundClass("2.ball throw.wav");
snd_ballDrop = new SoundClass("2.Ball drop.wav");
snd_rowUp = new SoundClass("3.ball row moves up1.wav");
snd_crowdCheer = new SoundClass("4.cheer alternative.wav");
snd_beepShort = new SoundClass("5.countdown beep soft.wav");
snd_beepLong = new SoundClass("5.countdown beep long.wav");
snd_loose = new SoundClass("6.boo.wav");
snd_alarm = new SoundClass("7. alarm loop.wav");
snd_ballPop1.setVolume(80);
snd_ballPop2.setVolume(80);
snd_ballPop3.setVolume(80);
snd_ballPop4.setVolume(80);
snd_ballPop5.setVolume(80);
snd_ballThrow.setVolume(50);
snd_ballDrop.setVolume(50);
snd_beepShort.setVolume(50);
snd_loose.setVolume(20);
snd_alarm.setVolume(20);
}
function startMainEngine() {
_root.onEnterFrame = function () {
myLauncher.move(myController.getPosX());
switch (myLauncher.mode) {
case "stop" :
return;
case "launcher" :
myLauncher.moveBall_launcher();
return;
case "fall" :
myLauncher.moveBall_fall();
myLauncher.detectBalls();
myLauncher.detectBottom();
return;
case "slide" :
myLauncher.moveBall_slide();
}
};
}
function stopMainEngine() {
delete _root.onEnterFrame;
}
function startGame() {
startMainEngine();
myLevel.reset();
scoreSubmitted = false;
myGrid.removeAllLines();
myScore.init();
myLauncher.reset();
myLevel.stopLevelInterval();
}
function stopGame() {
stopMainEngine();
}
function doGameOver() {
stopMainEngine();
myLauncher.stopBall();
myLevel.stopLevelInterval();
myScore.stopTimer();
popup_finish();
snd_loose.play();
}
function playCascadindSound(arr, number) {
var count;
count = 0;
clearInterval(timeInt);
timeInt = setInterval(function () {
arr[random(arr.length)].play();
if ((++count) == number) {
clearInterval(timeInt);
}
}, 30);
}
function popup_start() {
mc = _root.attachMovie("mcPopupStart", "mcPopup", DEPTH_POPUP);
mc._x = 150.5;
mc._y = 292.5;
mc.callBack = startGame;
mc.btnStartGame.onRelease = function () {
mc.play();
};
snd_crowdCheer.play();
}
function popup_finish() {
mc = _root.attachMovie("mcPopupFinish", "mcPopup", DEPTH_POPUP);
mc._x = 147;
mc._y = 301.5;
mc.dispScore = myScore.getScore();
mc.callBack = startGame;
mc.btnPlayAgain.onRelease = function () {
mc.play();
};
mc.btnSubmitScore.onRelease = function () {
popup_SubmitScore();
};
}
function popup_SubmitScore() {
var mc;
mc = _root.attachMovie("mcPopupHST", "mcPopupHST", _root.DEPTH_HST);
mc.gotoAndPlay("submit");
mc.disp_score = myScore.getScore();
mc.btnRegister.onRelease = function () {
getURL ("javascript:register();");
};
mc.btnSubmitScore.onRelease = function () {
if (!scoreSubmitted) {
myHST.submitScore(submitScoreCallBack, mc.firstNameText, mc.lastNameText, mc.emailText, null, mc.checkBox.selected, myScore.getScore(), mc.outpMsg_txt);
} else {
mc.outpMsg_txt.text = "Score already Submitted";
}
};
mc.btnClose.onRelease = function () {
mc.gotoAndPlay("submit_exit");
highScoresOnPopup = false;
};
mc.callBack = function () {
mc.removeMovieClip();
};
}
function submitScoreCallBack() {
popup_HST();
scoreSubmitted = true;
}
function popup_HST() {
var mc;
mc = _root.attachMovie("mcPopupHST", "mcPopupHST", _root.DEPTH_HST);
mc.gotoAndPlay("highScores");
timeInt = setInterval(function () {
myHST.setTableMovieClip(mc, mc.outpMsg_txt);
myHST.loadTable();
clearInterval(timeInt);
}, 300);
mc.btnClose.onRelease = function () {
mc.gotoAndPlay("highScores_exit");
myHST.clearTable();
highScoresOnPopup = false;
};
mc.callBack = function () {
mc.removeMovieClip();
};
}
_focusrect = false;
Stage.showMenu = false;
DEPTH_GRID = 10000;
DEPTH_MOUSECONTROLLER = 20000;
DEPTH_NEWBALL = 30000;
DEPTH_LAUNCHER = 40000;
DEPTH_EXPLOSION = 50000;
DEPTH_POPUP = 60000;
DEPTH_BONUS = 70000 /* 0x011170 */;
DEPTH_HST = 80000 /* 0x013880 */;
DEPTH_SOUNDS = 90000 /* 0x015F90 */;
btnHighScores.onRelease = function () {
if (!highScoresOnPopup) {
highScoresOnPopup = true;
popup_HST();
} else {
highScoresOnPopup = false;
mcPopupHST.btnClose.onRelease();
}
};
btnSend2Friend.onRelease = function () {
getURL ("mailto:?subject=PEPSI Handball Game&body=Hi! \r\rCheck out the latest game from PEPSI: http://www.pepsi.co.uk/games\r");
};
btnLink.onRelease = function () {
getURL ("http://www.thirstforfootball.com", "_blank");
};
mcSound.btnSound.onRelease = function () {
if (SoundClass.soundOn) {
mcSound.gotoAndStop("off");
SoundClass.soundOn = false;
} else {
mcSound.gotoAndStop("on");
SoundClass.soundOn = true;
}
};
btnReset.onRelease = function () {
mcSound.gotoAndStop("on");
myGrid.removeAllLines();
myScore.init();
myLauncher.reset();
myLevel.stopLevelInterval();
initAll();
popup_start();
};
initAll();
popup_start();
Symbol 58 Button
on (rollOver) {
mcClip.gotoAndPlay("rollover");
}
on (rollOut, dragOut) {
mcClip.gotoAndPlay("rollout");
}
on (release) {
nextFrame();
}
Symbol 60 Button
on (rollOver) {
mcClip.gotoAndPlay("rollover");
}
on (rollOut, dragOut) {
mcClip.gotoAndPlay("rollout");
}
on (release) {
prevFrame();
}
Symbol 61 MovieClip Frame 1
selected = 0;
stop();
Symbol 61 MovieClip Frame 2
selected = 1;
Symbol 64 Button
on (release) {
getURL ("javascript:register();");
}
Symbol 69 MovieClip [mcPopupHST] Frame 15
stop();
btnBg.useHandCursor = false;
Selection.setFocus("emailTxt_txt");
Symbol 69 MovieClip [mcPopupHST] Frame 25
callBack();
Symbol 69 MovieClip [mcPopupHST] Frame 40
stop();
loader._visible = false;
loadPage();
btnBg.useHandCursor = false;
Symbol 69 MovieClip [mcPopupHST] Frame 50
callBack();
Symbol 72 MovieClip [mcExplosionBlock] Frame 9
this.removeMovieClip();
Symbol 89 MovieClip [mcBall] Frame 1
stop();
Symbol 96 MovieClip [mcLauncher] Frame 1
stop();
Symbol 96 MovieClip [mcLauncher] Frame 23
_root.snd_ballThrow.play();
Symbol 96 MovieClip [mcLauncher] Frame 27
stop();
Symbol 110 MovieClip [mcPopupFinish] Frame 50
stop();
Symbol 110 MovieClip [mcPopupFinish] Frame 58
callBack(arg);
this.removeMovieClip();
Symbol 116 MovieClip [mcPopupStart] Frame 10
stop();
Symbol 116 MovieClip [mcPopupStart] Frame 18
callBack(arg);
this.removeMovieClip();
Symbol 118 MovieClip [mcPopupLevel] Frame 40
callBack(arg);
this.removeMovieClip();
Symbol 181 MovieClip Frame 1
stop();
Symbol 187 MovieClip Frame 1
stop();
Symbol 187 MovieClip Frame 14
gotoAndPlay ("blink");
Symbol 214 MovieClip Frame 1
stop();
Symbol 215 MovieClip [__Packages.HighScoreTableClass] Frame 0
class HighScoreTableClass
{
var mc, urlStr, method, outpMsg, receiveVars, nameArr, scoreArr, scoreCount, table, mcTable, mask, arrUp, arrDown, arrScroller, scroll, scrollFlag, tMinPos, tMaxPos, sMinPos, sMaxPos, callBack;
function HighScoreTableClass (urlStr_arg, method_arg) {
mc = _root.createEmptyMovieClip("mcLoadVars", _root.DEPTH_Z_LOADVARS);
urlStr = urlStr_arg;
method = method_arg;
outpMsg.text = "";
}
function isBlank(str) {
if ((str == undefined) || (str == "")) {
return(true);
}
return(false);
}
function isValid(emailStr) {
var _local4;
var _local7;
var _local5;
var _local6;
var _local1;
var _local2;
_local4 = emailStr.indexOf("@");
_local7 = emailStr.lastIndexOf("@");
_local5 = emailStr.length;
if (((_local4 != _local7) || (_local4 < 1)) || (_local4 > (_local5 - 4))) {
return(false);
}
_local6 = emailStr.lastIndexOf(".");
if (((_local5 - _local6) < 3) || ((_local5 - _local6) > 5)) {
return(false);
}
_local2 = new Array(32, 126, 33, 35, 36, 37, 94, 38, 42, 40, 41, 43, 124, 61, 96, 91, 93, 123, 125, 59, 58, 60, 62, 44, 63, 47, 92, 34, 39, 13, 10);
_local1 = 0;
while (_local1 < _local2.length) {
if (emailStr.indexOf(chr(_local2[_local1])) >= 0) {
return(false);
}
_local1++;
}
return(true);
}
function saveScore(firstname_arg, lastname_arg, email_arg, age_arg, opt_arg, score_arg) {
var _local2;
_local2 = new LoadVars();
receiveVars = new LoadVars();
_local2.score = score_arg;
_local2.opt = opt_arg;
_local2.age = age_arg;
_local2.email = email_arg;
_local2.firstname = firstname_arg;
_local2.lastname = lastname_arg;
_local2.todo = "saveScore";
_local2.sendAndLoad(urlStr, receiveVars, method);
outpMsg.text = "saving score...";
mc.handler = this;
mc.onEnterFrame = function () {
if (this.handler.receiveVars.result != undefined) {
delete this.handler.mc.onEnterFrame;
if (this.handler.receiveVars.result == "success") {
if (Number(this.handler.receiveVars.subscribed) == 0) {
getURL ("javascript:register();");
}
this.handler.outpMsg.text = "score saved - launching HST...";
this.handler.callBack();
} else if (this.handler.receiveVars.code == "1") {
this.handler.outpMsg.text = "There has been an error - Please try again";
} else if (this.handler.receiveVars.code == "3") {
this.handler.outpMsg.text = "There has been an error in retrieving the high scores table";
} else {
this.handler.outpMsg.text = "Please register first.";
}
}
};
}
function parseData(obj) {
var _local6;
var _local4;
var _local2;
var _local3;
nameArr = new Array();
scoreArr = new Array();
for (_local4 in obj) {
_local2 = _local4;
_local3 = obj[_local4];
if (_local2 == "scorecount") {
scoreCount = Number(_local3);
}
if (_local2.substr(0, 4) == "name") {
if (!isNaN(_local2.substr(4))) {
nameArr[Number(_local2.substr(4)) - 1] = _local3;
}
}
if (_local2.substr(0, 5) == "score") {
if (!isNaN(_local2.substr(5))) {
scoreArr[Number(_local2.substr(5)) - 1] = _local3;
}
}
}
populateTable();
}
function populateTable() {
var _local2;
var _local6;
var _local4;
var _local5;
var _local3;
_local6 = 16;
clearTable();
outpMsg.text = "";
table = mcTable.createEmptyMovieClip("mcTableGraphic", 1);
table._x = 37.5;
table._y = 26;
_local2 = 0;
while (_local2 < scoreCount) {
_local4 = _local2;
_local5 = "cell" + _local2;
_local3 = table.attachMovie("mcTableCell", _local5, _local4++);
_local3._x = 0;
_local3._y = _local2 * _local6;
_local3.gotoAndStop((_local2 % 2) + 1);
_local3.dispRank.text = ((_local2 < 9) ? (("0" + (_local2 + 1)) + ".") : ((_local2 + 1) + "."));
_local3.dispName.text = nameArr[_local2].toString();
_local3.dispScore.text = scoreArr[_local2].toString();
_local2++;
}
if (scoreCount > 30) {
mask = mcTable.attachMovie("mcTableMask", "mcMask", 2);
mask._x = 37.5;
mask._y = 26;
table.setMask(mask);
arrUp = mcTable.attachMovie("mcArrowUp", "mcArrowUp", 3);
arrDown = mcTable.attachMovie("mcArrowDown", "mcArrowDown", 4);
arrScroller = mcTable.attachMovie("mcArrowScroller", "mcArrowScroller", 5);
arrUp._x = (arrDown._x = (arrScroller._x = 260.5));
arrUp._y = 28;
arrDown._y = 500;
arrScroller._y = 28;
arrUp._visible = (arrDown._visible = false);
scroll = 0;
scrollFlag = false;
tMinPos = table._y - ((scoreCount - 30) * _local6);
tMaxPos = table._y;
sMinPos = arrScroller._y;
sMaxPos = sMinPos + ((arrDown._y - arrUp._y) - 50);
table.handler = this;
arrUp.handler = this;
arrDown.handler = this;
arrScroller.handler = this;
table.onEnterFrame = function () {
this._y = this._y + this.handler.scroll;
if (this._y > this.handler.tMaxPos) {
this._y = this.handler.tMaxPos;
}
if (this._y < this.handler.tMinPos) {
this._y = this.handler.tMinPos;
}
if (!this.handler.scrollFlag) {
this.percentTable = 1 - ((this._y - this.handler.tMinPos) / (this.handler.tMaxPos - this.handler.tMinPos));
this.handler.arrScroller._y = (this.percentTable * (this.handler.sMaxPos - this.handler.sMinPos)) + this.handler.sMinPos;
}
if (this.handler.scrollFlag) {
this.percentScroller = 1 - ((this.handler.arrScroller._y - this.handler.sMinPos) / (this.handler.sMaxPos - this.handler.sMinPos));
this._y = (this.percentScroller * (this.handler.tMaxPos - this.handler.tMinPos)) + this.handler.tMinPos;
}
};
arrUp.onPress = function () {
this.handler.scroll = 5;
};
arrDown.onPress = function () {
this.handler.scroll = -5;
};
arrUp.onRelease = (arrDown.onRelease = (arrUp.onReleaseOutside = (arrDown.onReleaseOutside = function () {
this.handler.scroll = 0;
})));
arrScroller.onPress = function () {
this.startDrag(false, this._x, this.handler.sMinPos, this._x, this.handler.sMaxPos);
this.handler.scrollFlag = true;
};
arrScroller.onRelease = (arrScroller.onReleaseOutside = function () {
this.stopDrag();
this.handler.scrollFlag = false;
});
}
}
function submitScore(callBack_arg, firstname, lastname, email, age, opt, score, outpMsg_txt) {
var _local2;
trace("Submitting:");
trace("firstname: " + firstname);
trace("lastname: " + lastname);
trace("email: " + email);
trace("age: " + age);
trace("opt: " + opt);
trace("score: " + score);
outpMsg = outpMsg_txt;
callBack = callBack_arg;
_local2 = 0;
if (isBlank(firstname)) {
_local2++;
outpMsg.text = "please fill in your first name.";
}
if (isBlank(lastname)) {
_local2++;
outpMsg.text = "please fill in your last name.";
}
if (!isValid(email)) {
_local2++;
outpMsg.text = "please fill in a valid email address.";
}
if (_local2 == 0) {
saveScore(firstname, lastname, email, age, opt, score);
} else {
trace("Form Error");
}
}
function setTableMovieClip(mc_arg, outpMsg_txt) {
mcTable = mc_arg;
outpMsg = outpMsg_txt;
}
function loadTable() {
var _local2;
_local2 = new LoadVars();
receiveVars = new LoadVars();
_local2.todo = "getScores";
_local2.sendAndLoad(urlStr, receiveVars, method);
outpMsg.text = "Loading high scores...";
mc.handler = this;
mc.onEnterFrame = function () {
if (this.handler.receiveVars.result != undefined) {
delete this.handler.mc.onEnterFrame;
if (this.handler.receiveVars.result == "success") {
this.handler.outpMsg.text = "High scores loaded - parsing data...";
this.handler.parseData(this.handler.receiveVars);
} else if (this.handler.receiveVars.code == "1") {
this.handler.outpMsg.text = "There has been an error - Please try again";
} else if (this.handler.receiveVars.code == "3") {
this.handler.outpMsg.text = "There has been an error in retrieving the high scores table";
} else {
this.handler.outpMsg.text = "Loading error.";
}
}
};
}
function clearTable() {
table.removeMovieClip();
mask.removeMovieClip();
}
}
Symbol 216 MovieClip [__Packages.MouseControllerClass] Frame 0
class MouseControllerClass
{
var mc, x;
function MouseControllerClass () {
mc = _root.createEmptyMovieClip("UIMouseController", _root.DEPTH_MOUSECONTROLLER);
startController();
}
function startController() {
mc.handler = this;
mc.onEnterFrame = function () {
this.handler.x = _root._xmouse;
this.handler.y = _root._ymouse;
};
}
function stopController() {
delete mc.onEnterFrame;
}
function getPosX() {
return(x);
}
}
Symbol 217 MovieClip [__Packages.LevelClass] Frame 0
class LevelClass
{
var depth, numBallType, level, timeIntLevel, timeIntLine, numStartingLines;
function LevelClass (depth_arg) {
depth = depth_arg;
numBallType = 5;
level = 0;
}
function startLevelInterval() {
stopLevelInterval();
timeIntLevel = setInterval(function (handler) {
handler.increaseLevel();
_root.snd_crowdCheer.play();
clearInterval(handler.timeIntLevel);
}, 60000, this);
timeIntLine = setInterval(function (handler) {
_root.myGrid.addLine();
_root.snd_rowUp.play();
}, 4000, this);
}
function stopLevelInterval() {
clearInterval(timeIntLevel);
clearInterval(timeIntLine);
}
function reset() {
numBallType = 4;
level = 0;
numStartingLines = 0;
increaseLevel();
}
function increaseLevel() {
var _local3;
level++;
if ((numStartingLines++) > 7) {
numStartingLines = 7;
}
_root.myLauncher.stopBall();
_local3 = _root.attachMovie("mcPopupLevel", "mcPopup", depth);
_local3._x = 150.5;
_local3._y = 292.5;
_local3.dispLevel = "LEVEL " + level;
_local3.callBack = startLevelCallBack;
_local3.arg = this;
stopLevelInterval();
_root.myScore.stopTimer();
_root.myGrid.removeAllLines();
}
function startLevelCallBack(handler) {
var _local2;
_root.myLauncher.cock();
if (((handler.level % 3) == 0) && (handler.numBallType < 7)) {
handler.numBallType++;
}
_local2 = 1;
while (_local2 <= handler.numStartingLines) {
_root.myGrid.addLine();
_local2++;
}
handler.startLevelInterval();
_root.myScore.updateLevel(handler.level);
_root.myScore.startTimer();
_root.myScore.increaseLevel();
}
}
Symbol 218 MovieClip [__Packages.SoundClass] Frame 0
class SoundClass
{
static var depth, soundOn;
var mc, snd, volume;
function SoundClass (id_arg) {
var _local3;
var _local4;
if (depth == undefined) {
depth = 0;
} else {
depth++;
}
_local3 = "mcSound" + depth;
mc = _root.createEmptyMovieClip(_local3, _root.DEPTH_SOUNDS + depth);
_local4 = "sound" + depth;
snd = new Sound(mc);
snd.attachSound(id_arg);
}
static function init() {
depth = 0;
soundOn = true;
}
static function startAllSounds() {
soundOn = true;
}
static function stopAllSounds() {
soundOn = false;
}
function play() {
if (soundOn) {
snd.start();
}
}
function playLoop(loop) {
if (soundOn) {
snd.start(0, loop);
}
}
function stop() {
snd.stop();
}
function setVolume(volume) {
snd.setVolume(volume);
}
function fadeOut() {
volume = snd.getVolume();
mc.handler = this;
mc.onEnterFrame = function () {
this.handler.snd.setVolume((this.handler.volume = this.handler.volume - 3));
if (this.handler.volume < 0) {
delete this.handler.mc.onEnterFrame;
}
};
}
}
Symbol 219 MovieClip [__Packages.LauncherClass] Frame 0
class LauncherClass
{
var mc, xMin, xMax, bottomPos, gravity, pos, ballPos, ballVel, mcBall, startPos, endPos, ballType, mode, newBallType, readyStatus, timeIntFetch;
function LauncherClass (depth_arg) {
mc = _root.attachMovie("mcLauncher", "mcLauncher", depth_arg);
mc.setMask(_root.mcMask);
xMin = 31.5;
xMax = 269.5;
bottomPos = 539.5;
gravity = 0.9;
pos = new PointClass(100, 90);
mc._x = pos.x;
ballPos = new PointClass();
ballVel = new PointClass();
mc.handler = this;
mc.onMouseDown = function () {
if ((((_root._xmouse > 5) && (_root._xmouse < 290)) && (_root._ymouse > 50)) && (_root._ymouse < 560)) {
this.handler.launch();
}
};
changeMode("stop");
}
function updateBallPosition() {
mcBall._x = ballPos.x;
mcBall._y = ballPos.y;
}
function moveBallUp(hitBall) {
var _local5;
var _local3;
if ((ballPos.x - hitBall.pos.x) < 0) {
_local3 = _root.myGrid.findCoordNeighborOf(hitBall, "TL");
} else {
_local3 = _root.myGrid.findCoordNeighborOf(hitBall, "TR");
}
ballPos.x = _local3.x;
ballPos.y = _local3.y;
}
function hitBall(hitBall) {
var _local3;
var _local2;
changeMode("stop");
moveBallUp(hitBall);
_local3 = findNewPos(hitBall);
startPos = new PointClass(ballPos.x, ballPos.y);
endPos = new PointClass(_local3.x, _local3.y);
_local2 = new Vect2dClass(endPos.x - startPos.x, endPos.y - startPos.y);
if ((_local2.x != 0) && (_local2.y != 0)) {
_local2.normalise();
ballVel.x = _local2.x * 15;
ballVel.y = _local2.y * 15;
} else {
ballVel.x = 0;
ballVel.y = 0;
}
changeMode("slide");
moveBall_slide();
}
function findNewPos(hitBall) {
var _local5;
var _local4;
var _local6;
if ((ballPos.x - hitBall.pos.x) < 0) {
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "LL");
_local5 = _root.myGrid.findBallAtCoord(_local4);
switch (_local5) {
case null :
while (_local5 === null) {
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "BL");
_local6 = hitBall;
hitBall = _root.myGrid.findBallAtCoord(_local4);
if (hitBall == null) {
return(_root.myGrid.findCoordNeighborOf(_local6, "LL"));
}
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "LL");
_local5 = _root.myGrid.findBallAtCoord(_local4);
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "TL");
}
break;
case undefined :
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "TL");
break;
default :
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "TL");
}
} else {
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "RR");
_local5 = _root.myGrid.findBallAtCoord(_local4);
switch (_local5) {
case null :
while (_local5 === null) {
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "BR");
_local6 = hitBall;
hitBall = _root.myGrid.findBallAtCoord(_local4);
if (hitBall == null) {
return(_root.myGrid.findCoordNeighborOf(_local6, "RR"));
}
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "RR");
_local5 = _root.myGrid.findBallAtCoord(_local4);
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "TR");
}
break;
case undefined :
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "TR");
break;
default :
_local4 = _root.myGrid.findCoordNeighborOf(hitBall, "TR");
}
}
return(_local4);
}
function moveBallCallBack() {
_root.myGrid.addBallToGrid(ballType, ballPos.x, ballPos.y);
_root.myGrid.doAllCalculations("removeSameKindNeighbor");
cock();
}
function reset() {
mcBall.removeMovieClip();
mc.gotoAndStop("closed");
}
function stopBall() {
changeMode("stop");
mcBall._visible = false;
}
function changeMode(newMode_arg) {
if (newMode_arg != mode) {
mode = newMode_arg;
}
}
function move(x_arg) {
pos.x = x_arg;
if (pos.x < xMin) {
pos.x = xMin;
}
if (pos.x > xMax) {
pos.x = xMax;
}
mc._x = pos.x;
}
function moveBall_launcher() {
ballPos.x = pos.x;
ballPos.y = pos.y;
ballPos.x = ballPos.x + ballVel.x;
ballPos.y = ballPos.y + ballVel.y;
updateBallPosition();
}
function moveBall_fall() {
ballVel.y = ballVel.y + gravity;
ballPos.x = ballPos.x + ballVel.x;
ballPos.y = ballPos.y + ballVel.y;
updateBallPosition();
}
function moveBall_slide() {
ballPos.x = ballPos.x + ballVel.x;
ballPos.y = ballPos.y + ballVel.y;
if (((Math.abs(ballPos.x - endPos.x) + Math.abs(ballPos.y - endPos.y)) < 10) || (ballPos.y > endPos.y)) {
ballPos.x = endPos.x;
ballPos.y = endPos.y;
changeMode("stop");
moveBallCallBack();
}
mcBall._x = ballPos.x;
mcBall._y = ballPos.y;
updateBallPosition();
}
function updateSlideParametersWhenAddingNewLine(yStep) {
ballPos.y = ballPos.y + yStep;
endPos.y = endPos.y + yStep;
updateBallPosition();
}
function cock() {
ballType = ((newBallType == undefined) ? (random(_root.myLevel.numBallType)) : (newBallType));
mcBall = _root.attachMovie("mcBall", "mcBall", _root.DEPTH_NEWBALL);
mcBall.hitZone._visible = false;
mcBall.gotoAndStop(ballType + 1);
mcBall._visible = true;
readyStatus = true;
mc.gotoAndStop("closed");
changeMode("launcher");
ballPos.x = pos.x;
ballPos.y = pos.y;
ballVel.x = 0;
ballVel.y = 0;
}
function launch() {
if (readyStatus) {
changeMode("fall");
mc.gotoAndStop("open");
readyStatus = false;
clearInterval(timeIntFetch);
timeIntFetch = setInterval(function (handler) {
handler.fetchNewBall();
clearInterval(handler.timeIntFetch);
}, 100, this);
_root.snd_ballDrop.play();
}
}
function fetchNewBall() {
mc.gotoAndPlay("fetch");
newBallType = random(_root.myLevel.numBallType);
mc.mcNewBall.gotoAndStop(newBallType + 1);
mc.mcNewBall.hitZone._visible = false;
}
function detectBalls() {
var _local3;
var _local6;
var _local4;
var _local5;
var _local7;
var _local8;
_local4 = new Array();
for (_local3 in _root.myGrid.allBallArr) {
_local6 = _root.myGrid.allBallArr[_local3];
if (_local6.mc.hitZone.hitTest(ballPos.x, ballPos.y, true)) {
_local4.push(_local6);
}
}
if (_local4.length == 0) {
return(undefined);
}
if (_local4.length == 1) {
hitBall(_local4[0]);
} else if (_local4.length > 1) {
_local5 = new Array();
_local7 = 1000;
for (_local3 in _local4) {
_local5[_local3] = ((_local4[_local3].pos.x - ballPos.x) * (_local4[_local3].pos.x - ballPos.x)) + ((_local4[_local3].pos.y - ballPos.y) * (_local4[_local3].pos.y - ballPos.y));
if (_local5[_local3] < _local7) {
_local7 = _local5[_local3];
_local8 = _local3;
}
}
hitBall(_local4[_local8]);
}
}
function detectBottom() {
if (ballPos.y > bottomPos) {
ballPos = _root.myGrid.getBottomPos(ballPos);
updateBallPosition();
changeMode("stop");
moveBallCallBack();
}
}
}
Symbol 220 MovieClip [__Packages.PointClass] Frame 0
class PointClass
{
var x, y;
function PointClass (x_arg, y_arg) {
x = x_arg || 0;
y = y_arg || 0;
}
}
Symbol 221 MovieClip [__Packages.BallClass] Frame 0
class BallClass
{
static var sDepth;
var type, mc, pos, mode;
function BallClass (holder_arg, type_arg, x_arg, y_arg) {
var _local2;
((sDepth == undefined) ? ((sDepth = 0)) : (sDepth++));
type = type_arg;
_local2 = "ball" + sDepth;
mc = holder_arg.attachMovie("mcBall", _local2, sDepth);
mc.hitZone._visible = false;
mc.gotoAndStop(type_arg + 1);
pos = new PointClass(x_arg, y_arg);
updatePosition();
mc.id = sDepth;
changeMode("unselected");
}
function updatePosition() {
mc._x = pos.x;
mc._y = pos.y;
}
function changeMode(newMode_arg) {
if (newMode_arg != mode) {
mode = newMode_arg;
}
switch (mode) {
case "unselected" :
break;
case "selected" :
break;
case "vanish" :
new ExplosionClipClass(mc, "mcExplosionBlock", null);
mc.removeMovieClip();
}
}
}
Symbol 222 MovieClip [__Packages.ExplosionClipClass] Frame 0
class ExplosionClipClass
{
static var depth;
var mc;
function ExplosionClipClass (mcHandler_arg, idClip_arg, callBack_arg) {
if (depth == undefined) {
depth = 0;
} else {
depth++;
}
mc = _root.attachMovie(idClip_arg, "mcExplosion" + depth, _root.DEPTH_EXPLOSION + depth);
mc._x = mcHandler_arg._x;
mc._y = mcHandler_arg._y;
mc.callBack = callBack_arg;
}
}
Symbol 223 MovieClip [__Packages.Vect2dClass] Frame 0
class Vect2dClass
{
var x, y, norm, phi;
function Vect2dClass (x_arg, y_arg) {
x = x_arg || 0;
y = y_arg || 0;
}
function setVal(x_arg, y_arg) {
x = x_arg;
y = y_arg;
}
function findNorm() {
return(Math.sqrt((x * x) + (y * y)));
}
function convertToPolarCoord() {
norm = findNorm();
phi = Math.atan2(y, x);
}
function convertToRectCoord() {
x = norm * Math.cos(phi);
y = norm * Math.sin(phi);
}
function normalise() {
var _local2 = findNorm();
x = x / _local2;
y = y / _local2;
}
function toString() {
trace("--------------------");
trace((("x = " + x) + " - y = ") + y);
trace((("norm = " + norm) + " - phi = ") + phi);
}
}
Symbol 224 MovieClip [__Packages.ScoreClass] Frame 0
class ScoreClass
{
var mc, mainScore, timer, sDepth, dispLevel, timeInt;
function ScoreClass (mc_arg) {
mc = mc_arg;
init();
}
function updateDisplay() {
var _local2 = mainScore.toString().length;
mc.disp_text = mainScore.toString();
switch (_local2) {
case 0 :
mc.disp_digit1 = "";
mc.disp_digit2 = "";
mc.disp_digit3 = "";
mc.disp_digit4 = "";
mc.disp_digit5 = "";
mc.disp_digit6 = "";
break;
case 1 :
mc.disp_digit1 = mainScore.toString().substr(_local2 - 1, 1);
mc.disp_digit2 = "";
mc.disp_digit3 = "";
mc.disp_digit4 = "";
mc.disp_digit5 = "";
mc.disp_digit6 = "";
break;
case 2 :
mc.disp_digit1 = mainScore.toString().substr(_local2 - 1, 1);
mc.disp_digit2 = mainScore.toString().substr(_local2 - 2, 1);
mc.disp_digit3 = "";
mc.disp_digit4 = "";
mc.disp_digit5 = "";
mc.disp_digit6 = "";
break;
case 3 :
mc.disp_digit1 = mainScore.toString().substr(_local2 - 1, 1);
mc.disp_digit2 = mainScore.toString().substr(_local2 - 2, 1);
mc.disp_digit3 = mainScore.toString().substr(_local2 - 3, 1);
mc.disp_digit4 = "";
mc.disp_digit5 = "";
mc.disp_digit6 = "";
break;
case 4 :
mc.disp_digit1 = mainScore.toString().substr(_local2 - 1, 1);
mc.disp_digit2 = mainScore.toString().substr(_local2 - 2, 1);
mc.disp_digit3 = mainScore.toString().substr(_local2 - 3, 1);
mc.disp_digit4 = mainScore.toString().substr(_local2 - 4, 1);
mc.disp_digit5 = "";
mc.disp_digit6 = "";
break;
case 5 :
mc.disp_digit1 = mainScore.toString().substr(_local2 - 1, 1);
mc.disp_digit2 = mainScore.toString().substr(_local2 - 2, 1);
mc.disp_digit3 = mainScore.toString().substr(_local2 - 3, 1);
mc.disp_digit4 = mainScore.toString().substr(_local2 - 4, 1);
mc.disp_digit5 = mainScore.toString().substr(_local2 - 5, 1);
mc.disp_digit6 = "";
break;
case 6 :
mc.disp_digit1 = mainScore.toString().substr(_local2 - 1, 1);
mc.disp_digit2 = mainScore.toString().substr(_local2 - 2, 1);
mc.disp_digit3 = mainScore.toString().substr(_local2 - 3, 1);
mc.disp_digit4 = mainScore.toString().substr(_local2 - 4, 1);
mc.disp_digit5 = mainScore.toString().substr(_local2 - 5, 1);
mc.disp_digit6 = mainScore.toString().substr(_local2 - 6, 1);
}
trace("score: " + mc.disp_text);
}
function updateTimerDisplay() {
var _local2 = timer.toString().length;
if (timer <= 10) {
mc.mcTimer.gotoAndPlay(1);
} else {
mc.mcTimer.gotoAndStop(1);
}
switch (_local2) {
case 0 :
mc.mcTimer.disp_timer1 = "";
mc.mcTimer.disp_timer2 = "";
break;
case 1 :
mc.mcTimer.disp_timer1 = timer.toString().substr(_local2 - 1, 1);
mc.mcTimer.disp_timer2 = "";
break;
case 2 :
mc.mcTimer.disp_timer1 = timer.toString().substr(_local2 - 1, 1);
mc.mcTimer.disp_timer2 = timer.toString().substr(_local2 - 2, 1);
}
}
function init() {
sDepth = 0;
mainScore = 0;
updateDisplay();
timer = 60;
updateTimerDisplay();
stopTimer();
dispLevel = 0;
}
function getScore() {
return(mainScore);
}
function startTimer() {
timer = 60;
timer--;
updateTimerDisplay();
clearInterval(timeInt);
timeInt = setInterval(function (handler) {
handler.timer--;
handler.updateTimerDisplay();
if ((handler.timer <= 10) && (handler.timer != 0)) {
_root.snd_beepShort.play();
}
if (handler.timer == 0) {
_root.snd_beepLong.play();
}
}, 1000, this);
}
function stopTimer() {
clearInterval(timeInt);
}
function increaseLevel() {
dispLevel++;
if (dispLevel > 20) {
dispLevel = dispLevel - 20;
}
mc.mcDisplayLevel.gotoAndStop(dispLevel);
}
function addBonus(type_arg, value_arg, x, y) {
var _local3;
sDepth++;
_local3 = _root.attachMovie("mcBonus", "mcBonus" + sDepth, sDepth + _root.DEPTH_BONUS);
_local3._x = x;
_local3._y = y;
_local3.handler = this;
_local3.onEnterFrame = function () {
this._y = this._y - 3;
this._alpha = this._alpha - 3;
if (this._alpha <= 0) {
this.removeMovieClip();
}
};
if (!(type_arg === "ball")) {
} else {
_local3.disp1 = (_local3.disp2 = "+" + value_arg.toString());
mainScore = mainScore + value_arg;
}
updateDisplay();
}
}
Symbol 225 MovieClip [__Packages.GridClass] Frame 0
class GridClass
{
var mc, xStart, yStart, xStep, yStep, dxLine, lineNumber, upperLimit, leftLimit, rightLimit, allBallArr, numBallType, neighborArr, lastAddedBall, ballToMoveArr, timeInt1, timeInt2, timeInt3;
function GridClass (depth_arg) {
mc = _root.createEmptyMovieClip("mcGrid", depth_arg);
xStart = 46.5;
yStart = 539.5;
xStep = 32;
yStep = -28;
dxLine = -16;
lineNumber = 0;
upperLimit = yStart + (14 * yStep);
leftLimit = ((0 * xStep) + (1 * dxLine)) + xStart;
rightLimit = ((7 * xStep) + (0 * dxLine)) + xStart;
allBallArr = new Array();
}
function moveAllBallUp() {
var _local2;
for (_local2 in allBallArr) {
allBallArr[_local2].pos.y = allBallArr[_local2].pos.y + yStep;
allBallArr[_local2].updatePosition();
}
}
function createNewBottomLine() {
var _local3;
var _local6;
var _local5;
var _local4;
numBallType = _root.myLevel.numBallType;
_local3 = 0;
while (_local3 < 8) {
_local4 = random(numBallType);
_local6 = ((_local3 * xStep) + ((lineNumber % 2) * dxLine)) + xStart;
_local5 = yStart;
allBallArr.push(new BallClass(mc, _local4, _local6, _local5));
_local3++;
}
lineNumber++;
}
function findNeighbors(ball) {
var _local3;
var _local2;
_local3 = findCoordNeighborOf(ball, "LL");
_local2 = findBallAtCoord(_local3);
if (_local2 != null) {
neighborArr.push(_local2);
}
_local3 = findCoordNeighborOf(ball, "RR");
_local2 = findBallAtCoord(_local3);
if (_local2 != null) {
neighborArr.push(_local2);
}
_local3 = findCoordNeighborOf(ball, "TL");
_local2 = findBallAtCoord(_local3);
if (_local2 != null) {
neighborArr.push(_local2);
}
_local3 = findCoordNeighborOf(ball, "TR");
_local2 = findBallAtCoord(_local3);
if (_local2 != null) {
neighborArr.push(_local2);
}
_local3 = findCoordNeighborOf(ball, "BL");
_local2 = findBallAtCoord(_local3);
if (_local2 != null) {
neighborArr.push(_local2);
}
_local3 = findCoordNeighborOf(ball, "BR");
_local2 = findBallAtCoord(_local3);
if (_local2 != null) {
neighborArr.push(_local2);
}
}
function selectCascadingNeighbors(ball) {
var _local3;
var _local2;
for (_local3 in neighborArr) {
_local2 = neighborArr[_local3];
if ((_local2.type == ball.type) && (_local2.mode == "unselected")) {
neighborArr.push(_local2);
_local2.changeMode("selected");
findNeighbors(_local2);
selectCascadingNeighbors(_local2);
}
}
}
function removeFromGrid(arr) {
var _local5;
var _local3;
var _local6;
var _local7;
_local6 = 0;
_local7 = 0;
for (_local5 in allBallArr) {
for (_local3 in arr) {
if (allBallArr[_local5] == arr[_local3]) {
arr[_local3].changeMode("vanish");
allBallArr.splice(_local5, 1);
_local7++;
((arr[_local3].type == 0) ? (_local6 = _local6 + 20) : (_local6 = _local6 + 10));
}
}
}
_root.myScore.addBonus("ball", _local6, arr[_local3].pos.x, arr[_local3].pos.y);
_root.playCascadindSound(_root.snd_ballPopArr, _local7);
}
function checkBallsHeight() {
var _local3;
var _local4;
_local4 = 10000;
for (_local3 in allBallArr) {
if (allBallArr[_local3].pos.y <= upperLimit) {
_root.doGameOver();
}
if ((allBallArr[_local3].pos.y - upperLimit) < _local4) {
_local4 = allBallArr[_local3].pos.y - upperLimit;
}
}
if (_local4 < 100) {
_root.mcLine.gotoAndPlay("blink");
_root.snd_alarm.play();
} else {
_root.mcLine.gotoAndStop("stop");
}
}
function removeAllLines() {
var _local2;
for (_local2 in allBallArr) {
allBallArr[_local2].changeMode("vanish");
}
allBallArr = new Array();
lineNumber = 0;
}
function addLine() {
moveAllBallUp();
createNewBottomLine();
checkBallsHeight();
if (_root.myLauncher.mode == "slide") {
_root.myLauncher.updateSlideParametersWhenAddingNewLine(yStep);
}
}
function findCoordNeighborOf(ball, location) {
var _local3;
var _local6;
var _local4;
switch (location) {
case "LL" :
_local3 = new PointClass(ball.pos.x - xStep, ball.pos.y);
break;
case "RR" :
_local3 = new PointClass(ball.pos.x + xStep, ball.pos.y);
break;
case "TL" :
_local3 = new PointClass(ball.pos.x + dxLine, ball.pos.y + yStep);
break;
case "BL" :
_local3 = new PointClass(ball.pos.x + dxLine, ball.pos.y - yStep);
break;
case "TR" :
_local3 = new PointClass(ball.pos.x - dxLine, ball.pos.y + yStep);
break;
case "BR" :
_local3 = new PointClass(ball.pos.x - dxLine, ball.pos.y - yStep);
}
return(_local3);
}
function findBallAtCoord(coord) {
var _local2;
var _local4;
if (((coord.x > rightLimit) || (coord.x < leftLimit)) || (coord.y > yStart)) {
return(undefined);
}
for (_local2 in allBallArr) {
if ((allBallArr[_local2].pos.x == coord.x) && (allBallArr[_local2].pos.y == coord.y)) {
return(allBallArr[_local2]);
}
}
return(null);
}
function addBallToGrid(ballType, x, y) {
lastAddedBall = new BallClass(mc, ballType, x, y);
allBallArr.push(lastAddedBall);
}
function getBottomPos(endPos) {
var _local6;
var _local7;
var _local2;
var _local3;
var _local4;
_local6 = new PointClass(endPos.x, yStart);
_local4 = 1000;
_local7 = dxLine * (lineNumber % 2);
_local3 = 0;
while (_local3 < 8) {
_local2 = ((_local3 * xStep) + (((lineNumber + 1) % 2) * dxLine)) + xStart;
if (Math.abs(endPos.x - _local2) < _local4) {
_local4 = Math.abs(endPos.x - _local2);
_local6.x = _local2;
}
_local3++;
}
return(_local6);
}
function removeSameKindNeighbor() {
var _local5;
var _local4;
var _local2;
var _local3;
for (_local2 in allBallArr) {
allBallArr[_local2].changeMode("unselected");
}
neighborArr = new Array();
neighborArr.push(lastAddedBall);
selectCascadingNeighbors(lastAddedBall);
_local3 = new Array();
for (_local2 in allBallArr) {
if (allBallArr[_local2].mode == "selected") {
_local3.push(allBallArr[_local2]);
}
}
if (_local3.length > 2) {
removeFromGrid(_local3);
}
doAllCalculations("findBallToMove");
}
function findBallToMove() {
var _local8;
var _local5;
var _local3;
var _local7;
var _local6;
var _local2;
var _local4;
ballToMoveArr = new Array();
do {
_local4 = 0;
for (_local8 in allBallArr) {
_local2 = allBallArr[_local8];
_local5 = findCoordNeighborOf(_local2, "BL");
_local3 = findCoordNeighborOf(_local2, "BR");
_local7 = findBallAtCoord(_local5);
_local6 = findBallAtCoord(_local3);
if (_local6 === null) {
_local2.pos = _local3;
_local2.updatePosition();
_local4++;
ballToMoveArr.push(_local2);
}
if (_local7 === null) {
_local2.pos = _local5;
_local2.updatePosition();
_local4++;
ballToMoveArr.push(_local2);
}
}
} while (_local4 != 0);
if (ballToMoveArr.length > 0) {
doAllCalculations("removeSameKindNeighbor_fromMovedBall");
}
}
function removeSameKindNeighbor_fromMovedBall() {
var _local2;
var _local3;
for (_local2 in ballToMoveArr) {
for (_local3 in ballToMoveArr) {
if ((ballToMoveArr[_local2] == ballToMoveArr[_local3]) && (_local2 != _local3)) {
ballToMoveArr.splice(_local2, 1);
}
}
}
for (_local2 in ballToMoveArr) {
lastAddedBall = ballToMoveArr[_local2];
removeSameKindNeighbor();
}
}
function doAllCalculations(action) {
clearInterval(timeInt1);
clearInterval(timeInt2);
clearInterval(timeInt3);
switch (action) {
case "removeSameKindNeighbor" :
timeInt1 = setInterval(function (handler) {
handler.removeSameKindNeighbor();
clearInterval(handler.timeInt1);
}, 100, this);
break;
case "findBallToMove" :
timeInt2 = setInterval(function (handler) {
handler.findBallToMove();
clearInterval(handler.timeInt2);
}, 100, this);
break;
case "removeSameKindNeighbor_fromMovedBall" :
timeInt3 = setInterval(function (handler) {
handler.removeSameKindNeighbor_fromMovedBall();
clearInterval(handler.timeInt3);
}, 100, this);
}
}
}