Frame 100
stop();
loadMovieNum ("http://watches.whodidit.co.uk/watch44.swf", 10);
_global.buttonOverSFX = new Sound(this);
_global.buttonOverSFX.attachSound("buttonOverSFX");
_global.buttonDownSFX = new Sound(this);
_global.buttonDownSFX.attachSound("buttonDownSFX");
Frame 110
Ellipse = function (width, height) {
this.width = width;
this.height = height;
var wRadius = (width >> 1);
var hRadius = (height >> 1);
this.focus = Math.sqrt((wRadius * wRadius) - (hRadius * hRadius));
return(this);
};
Ellipse.prototype.pointInEllipse = function (x, y) {
var dx1 = (x - this.focus);
var dx2 = (x + this.focus);
var yy = (y * y);
var focus1Dist = Math.sqrt((dx1 * dx1) + yy);
var focus2Dist = Math.sqrt((dx2 * dx2) + yy);
return((focus1Dist + focus2Dist) < this.width);
};
Object.registerClass("Ellipse", Ellipse);
Game = function () {
this.innings;
this.mc;
this.state;
this.userScore;
this.total;
this.overs;
this.ballNum;
this.wickets;
this.lastInnings;
this.inningsNum;
this.batsman;
this.bowler;
this.fielders;
this.counter;
this.mouseListener;
this.caughtOut;
this.ballWithinBoundary;
this.ballOverBoundaryValue;
this.numSixes;
this.numFours;
this.numBalls;
this.numOuts;
this.bowlDuration = 15;
this.battingLeeway = 5;
this.teamSize = 11;
this.fielderSpread = [3, 3, 3, 1];
this.maxOvers = 4;
this.friction = 0.96;
this.minPitchScale = 37;
this.ring1 = new Ellipse(740, 556);
this.ring2 = new Ellipse(1054, 792);
this.pitchEllipse = new Ellipse(1278, 1003);
this.boundaryEllipse = new Ellipse(1648, 1373);
this.creaseEllipse = new Ellipse(500, 260);
this.previousAngle = null;
_global.teamScore = 0;
_global.teamWickets = 0;
_global.opponentScore = 0;
_global.opponentWickets = 0;
_global.userSixes = 0;
_global.userFours = 0;
_global.strikeRate = 0;
_global.battingRate = 0;
this.fielderPositions = [[], [], [], []];
this.fielderPositions[0].push([[35, -453], [101, -430], [167, -443], [204, -415], [251, -429], [251, -382]]);
this.fielderPositions[0].push([[-327, -410], [-346, -371], [-386, -332], [-457, -275], [-489, -217]]);
this.fielderPositions[0].push([[-489, 195], [-467, 235], [-423, 271], [-373, 302], [-327, 332]]);
this.fielderPositions[0].push([[18, 424], [56, 392], [106, 401], [139, 379], [221, 379]]);
this.fielderPositions[1].push([[160, -288], [159, -365], [56, -382], [85, -315], [144, -332]]);
this.fielderPositions[1].push([[-305, -328], [-360, -282], [-411, -207], [-397, -151], [-337, -193]]);
this.fielderPositions[1].push([[-294, 282], [-287, 208], [-360, 192], [-344, 145], [-454, 172]]);
this.fielderPositions[1].push([[158, 248], [125, 284], [104, 324], [75, 271], [35, 353]]);
this.fielderPositions[2].push([[44, -257], [85, -125], [106, -193], [-60, -193], [21, -179]]);
this.fielderPositions[2].push([[-78, 150], [80, 149], [58, 234], [18, 184], [154, 184]]);
this.fielderPositions[2].push([[-164, -189], [-114, -145], [-277, -84], [-255, 62], [-190, 115], [-154, 184]]);
this.fielderPositions[3].push([[226, 0]]);
};
Game.prototype.init = function (mc, innings) {
this.mc = mc;
this.innings = innings;
this.batsman = mc.pitch.batsman;
this.bowler = mc.pitch.bowler;
this.fielders = [];
var i = 0;
while (i < (this.teamSize - 1)) {
var f = mc.pitch["fielder" + i];
f.faceTarget();
if (innings == "field") {
f.hat.gotoAndStop(_global.teamColour);
} else {
f.hat.gotoAndStop(_global.opponentColour);
}
this.fielders.push(f);
i++;
}
this.total = 0;
this.overs = 1;
this.ballNum = 1;
this.wickets = 0;
this.numSixes = 0;
this.numFours = 0;
this.numBalls = 0;
this.numOuts = 0;
this.lastInnings = 0;
this.inningsNum = 1;
this.xStep = 0;
this.yStep = 0;
this.mc.pitch.x0 = this.mc.pitch._x;
this.mc.pitch.y0 = this.mc.pitch._y;
this.ballRadius = mc.pitch.ball._width / 2;
this.randomiseFielderPositions();
this.updateScoreboard();
this.updateSmallPitch();
this.mc.message.gotoAndStop("hidden");
this.mc.playButton._visible = false;
this.mc.changeFieldersButton._visible = false;
this.mc.pitch.ball._visible = false;
this.mc.pitch.sixAreas._alpha = 0;
this.batsman.marker._xscale = (this.batsman.marker._yscale = 1);
this.lightHitAudio = new Sound(this.mc);
this.lightHitAudio.attachSound("lightHit");
this.mediumHitAudio = new Sound(this.mc);
this.mediumHitAudio.attachSound("mediumHit");
this.hardHitAudio = new Sound(this.mc);
this.hardHitAudio.attachSound("hardHit");
this.heavyHitAudio = new Sound(this.mc);
this.heavyHitAudio.attachSound("heavyHit");
this.caughtAudio = new Sound(this.mc);
this.caughtAudio.attachSound("caught");
this.bowledAudio = new Sound(this.mc);
this.bowledAudio.attachSound("bowled");
this.inningsAudio = new Sound(this.mc);
this.inningsAudio.attachSound("innings");
this.bgAudio = new Sound(this.mc);
this.bgAudio.attachSound("bgLoop");
this.bgAudio.start(0, 10000);
if (innings == "field") {
this.batsman.batsmanGraphic.ani.hat.gotoAndStop(_global.opponentColour);
this.zoomTo(this.minPitchScale);
this.state = 1;
} else if (innings == "bat") {
this.batsman.batsmanGraphic.ani.hat.gotoAndStop(_global.teamColour);
this.state = 3;
}
var callback = this;
this.mc.onEnterFrame = function () {
callback.update();
};
_global.gameInited = true;
_global.scoreSubmitted = false;
};
Game.prototype.update = function () {
switch (this.state) {
case -1 :
this.killEventLoop();
return;
case 0 :
return;
case 1 :
this.initFielders();
return;
case 2 :
this.updateFielders();
return;
case 3 :
this.autoInitFielders();
return;
case 4 :
this.initBowler();
return;
case 5 :
this.initBatsman();
return;
case 6 :
this.bowl();
return;
case 7 :
this.initBall();
return;
case 8 :
this.updateBall();
return;
case 9 :
this.followBall();
return;
case 10 :
this.finishBall();
}
};
Game.prototype.initFielders = function () {
var callback = this;
var counter = (this.fielders.length - 2);
var rings = [this.creaseEllipse, this.ring1, this.ring2, this.pitchEllipse];
var i = 0;
while (i < (this.fielderSpread.length - 1)) {
var j = 0;
while (j < this.fielderSpread[i]) {
this.fielders[counter].innerRing = rings[i];
this.fielders[counter].outerRing = rings[i + 1];
this.fielders[counter].init(1);
counter--;
j++;
}
i++;
}
if (((this.wickets == 0) && (this.overs == 1)) && (this.ballNum == 1)) {
this.mc.message.gotoAndStop("setFielders");
this.zoomTo(this.minPitchScale);
} else {
this.mc.changeFieldersButton._visible = true;
this.mc.changeFieldersButton.onRelease = function () {
callback.zoomTo(callback.minPitchScale);
this._visible = false;
};
}
this.mc.pitch.ball._visible = false;
this.bowler.init();
if (this.outMessageShowing) {
this.outMessageShowing = false;
this.mc.message.gotoAndStop("hidden");
}
this.messageTimer = setInterval(function () {
callback.mc.message.gotoAndStop("hidden");
clearInterval(callback.messageTimer);
}, 2400);
this.state = 2;
this.mc.playButton._visible = true;
this.mc.playButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
this.mc.playButton.onPress = function () {
_global.buttonDownSFX.start();
};
this.mc.playButton.onRelease = function () {
callback.state = 4;
};
};
Game.prototype.updateFielders = function () {
this.updateSmallPitch();
};
Game.prototype.autoInitFielders = function () {
this.randomiseFielderPositions();
if (((this.wickets == 0) && (this.overs == 1)) && (this.ballNum == 1)) {
this.mc.message.gotoAndStop("setBatsman");
var pauseTime = 3200;
} else {
this.mc.message.gotoAndStop("ready");
if (this.caughtOut) {
var pauseTime = 5000;
this.caughtOut = false;
} else {
var pauseTime = 1700;
}
}
this.mc.pitch.ball._visible = false;
this.bowler.init();
var mouseListener = new Object();
var callback = this;
this.messageTimer = setInterval(function () {
callback.mc.message.gotoAndStop("hidden");
callback.state = 5;
clearInterval(callback.messageTimer);
}, pauseTime);
this.updateSmallPitch();
this.state = 0;
};
Game.prototype.initBowler = function () {
this.caughtOut = false;
this.mc.playButton._visible = false;
this.mc.changeFieldersButton._visible = false;
if (((this.wickets == 0) && (this.overs == 1)) && (this.ballNum == 1)) {
this.mc.message.gotoAndStop("setBowler");
var mouseListener = new Object();
var callback = this;
Mouse.addListener(mouseListener);
mouseListener.onMouseDown = function () {
callback.mc.message.gotoAndStop("hidden");
Mouse.removeListener(this);
delete this;
};
}
var i = 0;
while (i < this.fielders.length) {
this.fielders[i].state = 3;
i++;
}
this.zoomTo(100);
this.bowler.init(1);
this.state = 0;
};
Game.prototype.initBatsman = function () {
this.numBalls++;
this.caughtOut = false;
var mouseListener = new Object();
var callback = this;
Mouse.addListener(mouseListener);
mouseListener.onMouseDown = function () {
callback.state = 6;
Mouse.removeListener(this);
delete this;
};
this.zoomTo(100);
this.batsman.init(1);
this.state = 0;
};
Game.prototype.bowl = function () {
this.bowler.init(4);
this.state = 0;
};
Game.prototype.initBall = function () {
if (this.innings == "field") {
var pt = {x:0, y:0};
this.batsman.init(4);
if (random(100) < 10) {
this.batsmanTrigger = (this.bowlDuration - this.batsman.numFramesToBat) + 1;
} else {
var batsmanHandicap = random(3);
this.batsmanTrigger = this.batsman.numFramesToBat + batsmanHandicap;
}
} else if (this.innings == "bat") {
var pt = {x:0, y:17};
}
this.ballWithinBoundary = true;
this.bowler.bowlerGraphic.localToGlobal(pt);
this.mc.pitch.globalToLocal(pt);
this.mc.pitch.ball._visible = true;
this.mc.pitch.ball._x = pt.x;
this.mc.pitch.ball._y = pt.y;
this.xGoal = 125;
this.yGoal = 0;
this.xStep = (this.xGoal - pt.x) / this.bowlDuration;
this.yStep = (this.yGoal - pt.y) / this.bowlDuration;
this.updateSmallPitch(this.mc.pitch.ball);
this.counter = 0;
this.state = 8;
};
Game.prototype.updateBall = function () {
this.mc.pitch.ball._x = this.mc.pitch.ball._x + this.xStep;
this.mc.pitch.ball._y = this.mc.pitch.ball._y + this.yStep;
this.mc.pitch.ball.gfx._rotation = this.mc.pitch.ball.gfx._rotation + 14;
this.updateSmallPitch(this.mc.pitch.ball);
if ((this.counter == (this.bowlDuration - this.batsmanTrigger)) && (this.innings == "field")) {
this.batsman.state = 5;
}
if ((++this.counter) == (this.bowlDuration + 1)) {
this.goingOut = true;
this.numOuts++;
this.mc.pitch.wicket.gotoAndPlay(2);
if (this.innings == "bat") {
this.mc.cutMask.showMovie("bowled");
} else {
this.outMessageShowing = true;
this.mc.message.gotoAndStop("out");
}
} else if (this.counter == (this.bowlDuration + 50)) {
if (this.goingOut) {
this.bowledAudio.start();
this.goingOut = false;
this.wickets++;
this.updateScoreboard();
this.xStep = 0;
this.yStep = 0;
this.counter = 0;
this.state = 10;
} else {
this.state = 3;
}
}
};
Game.prototype.checkHit = function (speed, angle, maxAngle) {
var impact = (this.bowlDuration - this.counter);
if ((impact < this.battingLeeway) && (impact >= 0)) {
var impactPenalty = (3 * impact);
var maxSpeed = 30;
if (speed > 0.75) {
this.heavyHitAudio.start();
} else if (speed > 0.5) {
this.hardHitAudio.start();
} else if (speed > 0.25) {
this.mediumHitAudio.start();
} else {
this.lightHitAudio.start();
}
var radAngle = ((Math.PI * maxAngle) / 180);
var meanSpeed = ((maxSpeed - impactPenalty) * speed);
var meanAngle = (radAngle * angle);
this.xStep = (-meanSpeed) * Math.cos(meanAngle);
this.yStep = (-meanSpeed) * Math.sin(meanAngle);
this.previousAngle = maxAngle * angle;
this.zoomTo(80);
this.state = 9;
}
};
Game.prototype.followBall = function () {
var ball = this.mc.pitch.ball;
var pMask = this.mc.pitchMask;
if (!this.caughtOut) {
ball._x = ball._x + this.xStep;
ball._y = ball._y + this.yStep;
ball.gfx._rotation = ball.gfx._rotation + (6 * (this.xStep + this.yStep));
this.checkFielders(ball._x, ball._y);
if (this.ballWithinBoundary && (!this.pitchEllipse.pointInEllipse(ball._x, ball._y))) {
var damping = 0.1;
this.xStep = damping * (-this.xStep);
this.yStep = damping * (-this.yStep);
this.ballWithinBoundary = false;
var pt = {x:ball._x, y:ball._y};
this.mc.pitch.localToGlobal(pt);
if (this.mc.pitch.sixAreas.hitTest(pt.x, pt.y, true)) {
this.caughtAudio.start();
this.ballOverBoundaryValue = 6;
if (this.innings == "bat") {
this.mc.cutMask.showMovie("six");
this.numSixes++;
}
} else {
this.bowledAudio.start();
this.ballOverBoundaryValue = 4;
if (this.innings == "bat") {
this.mc.cutMask.showMovie("four");
this.numFours++;
}
}
}
} else {
ball._x = ball._x + (0.3 * (this.xCatchingFielder - ball._x));
ball._y = ball._y + (0.3 * (this.yCatchingFielder - ball._y));
}
var xGoal = ((0.5 * pMask._width) - ball._x);
var yGoal = ((0.5 * pMask._height) - ball._y);
var xPitch = (this.mc.pitch._x + (0.3 * (xGoal - this.mc.pitch._x)));
var yPitch = (this.mc.pitch._y + (0.3 * (yGoal - this.mc.pitch._y)));
var pw = ((this.mc.pitch._xscale * this.mc.pitch.bg._width) / 200);
var ph = ((this.mc.pitch._yscale * this.mc.pitch.bg._height) / 200);
var leftEdge = (pMask._x + pw);
var topEdge = (pMask._y + ph);
var rightEdge = ((pMask._x + pMask._width) - pw);
var bottomEdge = ((pMask._y + pMask._height) - ph);
xPitch = Math.min(xPitch, leftEdge);
xPitch = Math.max(xPitch, rightEdge);
yPitch = Math.min(yPitch, topEdge);
yPitch = Math.max(yPitch, bottomEdge);
this.mc.pitch._x = xPitch;
this.mc.pitch._y = yPitch;
this.updateSmallPitch(this.mc.pitch.ball);
this.xStep = this.xStep * this.friction;
this.yStep = this.yStep * this.friction;
if ((Math.abs(this.xStep) < 0.2) && (Math.abs(this.yStep) < 0.2)) {
if (!this.caughtOut) {
var numRuns = 3;
if (this.ballWithinBoundary) {
if (this.ring1.pointInEllipse(ball._x, ball._y)) {
numRuns = 1;
} else if (this.ring2.pointInEllipse(ball._x, ball._y)) {
numRuns = 2;
}
} else {
numRuns = this.ballOverBoundaryValue;
}
if (((this.total < 100) && ((this.total + numRuns) >= 100)) && (this.innings == "bat")) {
this.mc.cutMask.showMovie("century");
}
this.total = this.total + numRuns;
}
this.updateScoreboard();
this.xStep = (this.mc.pitch.x0 - this.mc.pitch._x) / 30;
this.yStep = (this.mc.pitch.y0 - this.mc.pitch._y) / 30;
this.counter = 0;
this.state = 10;
}
};
Game.prototype.checkFielders = function (x, y) {
var bL = (x - this.ballRadius);
var bR = (x + this.ballRadius);
var bT = (y - this.ballRadius);
var bB = (y + this.ballRadius);
var i = -1;
while (i < this.fielders.length) {
var f = ((i == -1) ? (this.bowler) : (this.fielders[i]));
var fielderRadius = 25;
var fL = (f._x - fielderRadius);
var fR = (f._x + fielderRadius);
var fT = (f._y - fielderRadius);
var fB = (f._y + fielderRadius);
var dx = (x - f._x);
var dy = (y - f._y);
var dist = Math.sqrt((dx * dx) + (dy * dy));
var minDist = (fielderRadius + this.ballRadius);
if ((dist < 150) && (i != -1)) {
var angle = ((180 * Math.atan2(dy, dx)) / Math.PI);
var r = f._rotation;
if (Math.abs(angle - r) > 180) {
if (angle < 0) {
angle = 360 + angle;
} else {
r = 360 + r;
}
}
f._rotation = f._rotation + (0.1 * (angle - r));
f.setShadow();
}
if ((!this.caughtOut) && (dist < minDist)) {
var pt = {x:24, y:0};
f.localToGlobal(pt);
this.mc.pitch.globalToLocal(pt);
this.xCatchingFielder = pt.x;
this.yCatchingFielder = pt.y;
this.xStep = 0.4;
this.yStep = 0.4;
this.caughtOut = true;
this.wickets++;
this.numOuts++;
this.updateScoreboard();
this.caughtAudio.start();
if (this.innings == "field") {
this.outMessageShowing = true;
this.mc.message.gotoAndStop("out");
}
}
i++;
}
};
Game.prototype.finishBall = function () {
if (this.caughtOut && (this.innings == "bat")) {
if (this.counter == 0) {
this.mc.cutMask.showMovie("caught");
} else if (this.counter == 10) {
this.mc.pitch._x = this.mc.pitch._x + (30 * this.xStep);
this.mc.pitch._y = this.mc.pitch._y + (30 * this.yStep);
this.counter = 29;
}
} else {
this.mc.pitch._x = this.mc.pitch._x + this.xStep;
this.mc.pitch._y = this.mc.pitch._y + this.yStep;
}
if ((this.counter++) == 30) {
this.ballNum++;
if (this.ballNum == 7) {
this.overs++;
this.ballNum = 1;
}
if ((this.overs > this.maxOvers) || (this.wickets == this.teamSize)) {
if ((++this.inningsNum) > 2) {
this.endGame();
} else {
this.setNextInnings();
}
} else if (this.innings == "bat") {
this.state = 3;
} else {
this.state = 1;
}
this.mc.pitch._x = this.pitch.x0;
this.mc.pitch._y = this.pitch.y0;
this.updateScoreboard();
}
};
Game.prototype.endGame = function () {
if (this.innings == "bat") {
_global.teamScore = this.total;
_global.teamWickets = this.wickets;
_global.userSixes = this.numSixes;
_global.userFours = this.numFours;
var sr = (this.total / this.numBalls);
var br = (this.total / this.numOuts);
_global.strikeRate = Math.round(sr * 10) / 10;
_global.battingRate = Math.round(br * 10) / 10;
} else {
_global.opponentScore = this.total;
_global.opponentWickets = this.wickets;
}
this.mc.message.gotoAndStop("gameOver");
this.state = -1;
};
Game.prototype.setNextInnings = function () {
this.inningsAudio.start();
this.mc.message.gotoAndStop("nextInnings");
if (this.innings == "bat") {
_global.teamScore = this.total;
_global.teamWickets = this.wickets;
_global.userSixes = this.numSixes;
_global.userFours = this.numFours;
var sr = (this.total / this.numBalls);
var br = (this.total / this.numOuts);
_global.strikeRate = Math.round(sr * 10) / 10;
_global.battingRate = Math.round(br * 10) / 10;
this.innings = "field";
} else {
_global.opponentScore = this.total;
_global.opponentWickets = this.wickets;
this.innings = "bat";
}
this.previousAngle = null;
this.state = 0;
};
Game.prototype.randomiseFielderPositions = function () {
var seed;
var temp;
var pos;
var sixAreasOrder;
var i = 0;
while (i < this.fielderPositions.length) {
var j = 0;
while (j < this.fielderPositions[i].length) {
var k = 0;
while (k < this.fielderPositions[i][j].length) {
seed = k + random(this.fielderPositions[i][j].length - k);
temp = this.fielderPositions[i][j][seed];
this.fielderPositions[i][j][seed] = this.fielderPositions[i][j][k];
this.fielderPositions[i][j][k] = temp;
k++;
}
j++;
}
i++;
}
sixAreasOrder = [0, 1, 2, 3];
var i = 0;
while (i < sixAreasOrder.length) {
seed = i + random(sixAreasOrder.length - i);
temp = sixAreasOrder[seed];
sixAreasOrder[seed] = sixAreasOrder[i];
sixAreasOrder[i] = temp;
i++;
}
seed = random(this.fielderPositions[0][sixAreasOrder[0]].length);
pos = this.fielderPositions[0][sixAreasOrder[0]][seed];
this.fielders[0]._x = pos[0];
this.fielders[0]._y = pos[1];
seed = random(this.fielderPositions[0][sixAreasOrder[1]].length);
pos = this.fielderPositions[0][sixAreasOrder[1]][seed];
this.fielders[1]._x = pos[0];
this.fielders[1]._y = pos[1];
seed = random(this.fielderPositions[0][sixAreasOrder[2]].length);
pos = this.fielderPositions[0][sixAreasOrder[2]][seed];
this.fielders[2]._x = pos[0];
this.fielders[2]._y = pos[1];
seed = random(this.fielderPositions[1][sixAreasOrder[0]].length);
pos = this.fielderPositions[1][sixAreasOrder[0]][seed];
this.fielders[3]._x = pos[0];
this.fielders[3]._y = pos[1];
seed = random(this.fielderPositions[1][sixAreasOrder[1]].length);
pos = this.fielderPositions[1][sixAreasOrder[1]][seed];
this.fielders[4]._x = pos[0];
this.fielders[4]._y = pos[1];
seed = random(this.fielderPositions[1][sixAreasOrder[3]].length);
pos = this.fielderPositions[1][sixAreasOrder[3]][seed];
this.fielders[5]._x = pos[0];
this.fielders[5]._y = pos[1];
seed = random(this.fielderPositions[2][0].length);
pos = this.fielderPositions[2][0][seed];
this.fielders[6]._x = pos[0];
this.fielders[6]._y = pos[1];
seed = random(this.fielderPositions[2][1].length);
pos = this.fielderPositions[2][1][seed];
this.fielders[7]._x = pos[0];
this.fielders[7]._y = pos[1];
seed = random(this.fielderPositions[2][2].length);
pos = this.fielderPositions[2][2][seed];
this.fielders[8]._x = pos[0];
this.fielders[8]._y = pos[1];
seed = random(this.fielderPositions[3][0].length);
pos = this.fielderPositions[3][0][seed];
this.fielders[9]._x = pos[0];
this.fielders[9]._y = pos[1];
var i = 0;
while (i < this.fielders.length) {
this.fielders[i].faceTarget();
i++;
}
};
Game.prototype.updateScoreboard = function () {
var t = this.total;
if (this.total < 10) {
t = "0" + t;
}
if (this.total < 100) {
t = "0" + t;
}
var w = this.wickets;
if (this.wickets < 10) {
w = "0" + w;
}
var o = (this.overs - 1);
if (o < 10) {
o = "0" + o;
}
o = o + ("." + (this.ballNum - 1));
var li = this.lastInnings;
if (this.lastInnings < 10) {
li = "0" + li;
}
if (this.lastInnings < 100) {
li = "0" + li;
}
this.mc.scoreboard.total.text = t;
this.mc.scoreboard.wickets.text = w;
this.mc.scoreboard.overs.text = o;
this.mc.scoreboard.lastInnings.text = li;
};
Game.prototype.updateSmallPitch = function (mc) {
if (mc != undefined) {
var marker = this.mc.scoreboard.pitch[mc._name];
marker._x = 0.66 * mc._x;
marker._y = 0.66 * mc._y;
marker._rotation = mc._rotation;
marker._visible = mc._visible;
} else {
for (var i in this.mc.pitch) {
var marker = this.mc.scoreboard.pitch[this.mc.pitch[i]._name];
marker._x = 0.66 * this.mc.pitch[i]._x;
marker._y = 0.66 * this.mc.pitch[i]._y;
marker._rotation = this.mc.pitch[i]._rotation;
marker._visible = this.mc.pitch[i]._visible;
}
}
};
Game.prototype.zoomTo = function (scale) {
this.mc.pitch.goalScale = scale;
this.mc.pitch.onEnterFrame = function () {
this._xscale = this._xscale + (0.2 * (this.goalScale - this._xscale));
this._yscale = this._yscale + (0.2 * (this.goalScale - this._yscale));
if (Math.abs(this._xscale - this.goalScale) < 0.3) {
this._xscale = (this._yscale = this.goalScale);
delete this.onEnterFrame;
}
};
};
Game.prototype.killEventLoop = function () {
delete this.mc.onEnterFrame;
this.state = 0;
};
_global.game = new Game();
Symbol 6 MovieClip Frame 1
_visible = false;
Symbol 24 MovieClip Frame 1
stop();
Symbol 25 MovieClip Frame 1
stop();
Symbol 27 MovieClip [batsman] Frame 1
#initclip 3
Batsman = function () {
this.maxAngle = 120;
this.maxRadius = 180;
this.minAngle = -this.maxAngle;
this.minSpeed = 0.1;
this.numFramesToBat = 5;
this.angle;
this.speed;
this.counter;
this.state;
};
Batsman.prototype = new MovieClip();
Batsman.prototype.init = function (startState) {
this.state = startState;
this.angle = 0;
this.speed = 0;
this.counter = 0;
this.radar._visible = false;
this.marker._visible = true;
this.markerMask._rotation = 180;
this.batsmanGraphic._rotation = 0;
this.marker._xscale = (this.marker._yscale = 1);
this.onEnterFrame = this.update;
};
Batsman.prototype.update = function () {
switch (this.state) {
case -1 :
this.killEventLoop();
return;
case 0 :
return;
case 1 :
this.initUserInteraction();
return;
case 2 :
this.handleUserInteraction();
return;
case 3 :
this.initBat();
return;
case 4 :
this.initAutoBat();
return;
case 5 :
this.doBat();
}
};
Batsman.prototype.initUserInteraction = function () {
var callback = this;
this.hotSpot.onPress = function () {
callback.state = 2;
};
this.hotSpot.onRelease = function () {
callback.state = 3;
};
this.hotSpot.onReleaseOutside = function () {
callback.state = 3;
};
};
Batsman.prototype.handleUserInteraction = function () {
this.radar._visible = true;
var x = this._xmouse;
var y = this._ymouse;
var radius = Math.sqrt((x * x) + (y * y));
radius = Math.min(radius, this.maxRadius);
var degAngle = ((180 * Math.atan2(y, x)) / Math.PI);
degAngle = Math.min(degAngle, this.maxAngle);
degAngle = Math.max(degAngle, this.minAngle);
this.markerMask._rotation = degAngle + 180;
this.batsmanGraphic._rotation = degAngle;
this.marker._width = this.marker._width + (0.3 * ((2 * radius) - this.marker._width));
this.marker._height = this.marker._width;
this.angle = degAngle / this.maxAngle;
this.speed = radius / this.maxRadius;
this.speed = Math.max(this.minSpeed, this.speed);
};
Batsman.prototype.initBat = function () {
this.radar._visible = false;
if (_global.game.state == 0) {
this.init(1);
} else {
delete this.hotSpot.onPress;
delete this.hotSpot.onRelease;
delete this.hotSpot.onReleaseOutside;
this.counter = 0;
this.state = 5;
}
this.batsmanGraphic.ani.play();
};
Batsman.prototype.doBat = function () {
var angle = (0.3 * this.batsmanGraphic._rotation);
this.markerMask._rotation = angle + 180;
this.batsmanGraphic._rotation = angle;
var tween = (0.5 * this.marker._width);
this.marker._width = (this.marker._height = tween);
if (tween < 1) {
this.markerMask._rotation = 180;
this.batsmanGraphic._rotation = 0;
delete this.onEnterFrame;
}
if ((++this.counter) == this.numFramesToBat) {
this.checkHit();
}
};
Batsman.prototype.initAutoBat = function () {
if (random(100) < 10) {
this.angle = Math.random();
this.speed = (0.7 * Math.random()) + 0.3;
} else {
var badAngles = [[-3, 9]];
if (_global.game.previousAngle != null) {
badAngles.push([_global.game.previousAngle, _global.game.previousAngle]);
}
var i = 0;
while (i < _global.game.fielders.length) {
var fielderRadius = 27;
var x = (_global.game.fielders[i]._x - this._x);
var y = (_global.game.fielders[i]._y - this._y);
var dist = Math.sqrt((x * x) + (y * y));
var rad = Math.atan2(-y, -x);
var spread = Math.atan(fielderRadius / dist);
var rMin = int((180 * (rad - spread)) / Math.PI);
var rMax = int((180 * (rad + spread)) / Math.PI);
badAngles.push([rMin, rMax]);
i++;
}
var goodAngles = [];
var i = this.minAngle;
while (i <= this.maxAngle) {
var isGood = true;
var j = 0;
while (j < badAngles.length) {
if ((i >= badAngles[j][0]) && (i <= badAngles[j][1])) {
isGood = false;
break;
}
j++;
}
if (isGood) {
goodAngles.push(i);
}
i++;
}
if (goodAngles.length == 0) {
this.angle = Math.random();
this.speed = (0.7 * Math.random()) + 0.3;
} else {
var gaps = [];
var prev = (goodAngles[0] - 1);
var currGap = [];
var i = 0;
while (i < goodAngles.length) {
if (goodAngles[i] == (prev + 1)) {
currGap.push(goodAngles[i]);
} else {
gaps.push(currGap);
currGap = [];
}
prev = goodAngles[i];
i++;
}
if (currGap.length > 0) {
gaps.push(currGap);
}
var bigGapRef;
var bigGapSize = 0;
var i = 0;
while (i < gaps.length) {
if (gaps[i].length > bigGapSize) {
bigGapSize = gaps[i].length;
bigGapRef = i;
}
i++;
}
var midPosition = Math.round(gaps[bigGapRef].length / 2);
var midAngle = gaps[bigGapRef][midPosition];
this.angle = midAngle / this.maxAngle;
this.speed = 1;
}
}
this.batsmanGraphic._rotation = this.minAngle + (this.angle * (this.maxAngle - this.minAngle));
this.marker._visible = false;
this.marker._width = (this.marker._height = this.speed * this.maxRadius);
this.counter = 0;
this.state = 0;
this.batsmanGraphic.ani.play();
};
Batsman.prototype.checkHit = function () {
_global.game.checkHit(this.speed, this.angle, this.maxAngle);
};
Batsman.prototype.killEventLoop = function () {
delete this.onEnterFrame;
this.state = 0;
};
Object.registerClass("batsman", batsman);
#endinitclip
Symbol 36 MovieClip Frame 1
stop();
Symbol 41 MovieClip [bowler] Frame 1
#initclip 1
Bowler = function () {
this.maxRadius = 140;
this.maxAngle = 25;
this.minAngle = -25;
this.minSpeed = 0.1;
this.numFramesToBowl = 6;
this.bowlStep;
this.angle;
this.speed;
this.counter;
this.state;
this.bowlerGraphic.ball._y = 17;
this.marker._xscale = (this.marker._yscale = 1);
};
Bowler.prototype = new MovieClip();
Bowler.prototype.init = function (startState) {
this.state = startState;
this.angle = 0;
this.speed = 0;
this.counter = 0;
this.markerMask._rotation = 180;
this.batsmanGraphic._rotation = 0;
this.bowlerGraphic.ball._x = 0;
this.bowlerGraphic.ball._y = 17;
this.marker._xscale = (this.marker._yscale = 10);
this.onEnterFrame = this.update;
};
Bowler.prototype.update = function () {
switch (this.state) {
case -1 :
this.killEventLoop();
return;
case 0 :
return;
case 1 :
this.initUserInteraction();
return;
case 2 :
this.handleUserInteraction();
return;
case 3 :
this.initBowl();
return;
case 4 :
this.initAutoBowl();
return;
case 5 :
this.doBowl();
return;
case 6 :
this.autoBowl();
}
};
Bowler.prototype.initUserInteraction = function () {
this.bowlerGraphic.ball._visible = true;
this.marker._visible = true;
var callback = this;
this.hotSpot.onPress = function () {
callback.state = 2;
};
this.hotSpot.onRelease = function () {
callback.state = 3;
};
this.hotSpot.onReleaseOutside = function () {
callback.state = 3;
};
};
Bowler.prototype.handleUserInteraction = function () {
var x = this._xmouse;
var y = this._ymouse;
var radius = Math.sqrt((x * x) + (y * y));
radius = Math.min(radius, this.maxRadius);
this.markerMask._rotation = 0;
var angle = ((180 * Math.atan2(-y, -x)) / Math.PI);
angle = Math.min(angle, this.maxAngle);
angle = Math.max(angle, this.minAngle);
this.markerMask._rotation = angle;
this.bowlerGraphic._rotation = angle;
this.bowlerGraphic.ball._y = 0;
this.marker._width = this.marker._width + (0.3 * ((2 * radius) - this.marker._width));
this.marker._height = this.marker._width;
this.bowlerGraphic.ball._x = -0.5 * this.marker._height;
this.angle = (-angle) / this.maxAngle;
this.speed = radius / this.maxRadius;
this.speed = Math.max(this.minSpeed, this.speed);
};
Bowler.prototype.initBowl = function () {
delete this.hotSpot.onPress;
delete this.hotSpot.onRelease;
delete this.hotSpot.onReleaseOutside;
this.counter = 0;
this.bowlStep = (-this.bowlerGraphic.ball._x) / this.numFramesToBowl;
this.state = 5;
this.bowlerGraphic.ani.play();
};
Bowler.prototype.doBowl = function () {
var angle = (0.3 * this.bowlerGraphic._rotation);
this.markerMask._rotation = angle;
this.bowlerGraphic._rotation = angle;
var tween = (0.5 * this.marker._width);
this.marker._width = (this.marker._height = tween);
this.bowlerGraphic.ball._x = this.bowlerGraphic.ball._x + this.bowlStep;
if ((++this.counter) == this.numFramesToBowl) {
this.launchBall();
}
if ((tween < 1) && (this.counter >= this.numFramesToBowl)) {
this.markerMask._rotation = 180;
this.bowlerGraphic._rotation = 0;
delete this.onEnterFrame;
}
};
Bowler.prototype.initAutoBowl = function () {
this.bowlerGraphic.ball._visible = true;
this.angle = 0.5 + (0.5 * Math.random());
this.speed = (0.7 * Math.random()) + 0.3;
this.marker._visible = false;
this.marker._width = (this.marker._height = this.speed * this.maxRadius);
this.counter = 0;
this.bowlStep = 0;
this.state = 6;
this.bowlerGraphic.ani.play();
};
Bowler.prototype.launchBall = function () {
this.bowlerGraphic.ball._visible = false;
_global.game.state = 7;
};
Bowler.prototype.autoBowl = function () {
var r = this.bowlerGraphic._rotation;
var rGoal = (this.minAngle + (this.angle * (this.maxAngle - this.minAngle)));
var angle = (r + (0.08 * (rGoal - r)));
this.markerMask._rotation = angle;
this.bowlerGraphic._rotation = angle;
if (Math.abs(rGoal - r) < 0.1) {
this.state = 5;
}
};
Bowler.prototype.killEventLoop = function () {
delete this.onEnterFrame;
this.state = 0;
};
Object.registerClass("Bowler", Bowler);
#endinitclip
Symbol 46 MovieClip [teamButton] Frame 10
stop();
Symbol 50 MovieClip [fielder] Frame 1
#initclip 2
Fielder = function () {
this.xTarget = 100;
this.yTarget = 0;
this.innerRing;
this.outerRing;
this.state;
};
Fielder.prototype = new MovieClip();
Fielder.prototype.init = function (startState) {
this.state = startState;
this.faceTarget();
this.onEnterFrame = this.update;
};
Fielder.prototype.update = function () {
switch (this.state) {
case -1 :
this.killEventLoop();
return;
case 0 :
return;
case 1 :
this.initUserInteraction();
return;
case 2 :
this.handleUserInteraction();
return;
case 3 :
this.disableUserInteraction();
}
};
Fielder.prototype.initUserInteraction = function () {
this.onPress = function () {
this.state = 2;
};
this.onRelease = function () {
this.state = 0;
};
this.onReleaseOutside = function () {
this.state = 0;
};
};
Fielder.prototype.handleUserInteraction = function () {
var xNew = this._parent._xmouse;
var yNew = this._parent._ymouse;
if (this.checkCollision(xNew, yNew)) {
this._x = xNew;
this._y = yNew;
this.faceTarget();
}
};
Fielder.prototype.checkCollision = function (x, y) {
var innerRingOK = true;
var outerRingOK = true;
var overlapping = false;
if (this.innerRing != undefined) {
innerRingOK = !this.innerRing.pointInEllipse(x, y);
}
if (this.outerRing != undefined) {
outerRingOK = this.outerRing.pointInEllipse(x, y);
}
for (var i in this._parent) {
var f = this._parent[i];
if ((f instanceof Fielder) && (f != this)) {
var dx = (f._x - x);
var dy = (f._y - y);
if (((dx * dx) + (dy * dy)) < 2500) {
overlapping = true;
break;
}
}
}
return((innerRingOK && (outerRingOK)) && (!overlapping));
};
Fielder.prototype.disableUserInteraction = function () {
delete this.onPress;
delete this.onRelease;
delete this.onReleaseOutside;
};
Fielder.prototype.faceTarget = function () {
var dx = (this.xTarget - this._x);
var dy = (this.yTarget - this._y);
var angle = ((180 * Math.atan2(dy, dx)) / Math.PI);
this._rotation = angle;
this.setShadow();
};
Fielder.prototype.setShadow = function () {
var angle = ((Math.PI * this._rotation) / 180);
var shadowAngle = 5.49778714378214;
var xShadow = (5 * Math.sin(angle + shadowAngle));
var yShadow = (5 * Math.cos(angle + shadowAngle));
this.shadow._x = xShadow;
this.shadow._y = yShadow;
};
Fielder.prototype.killEventLoop = function () {
delete this.onEnterFrame;
this.state = 0;
};
Object.registerClass("Fielder", Fielder);
#endinitclip
Symbol 65 MovieClip Frame 99
stop();
Symbol 88 MovieClip Frame 1
init = function () {
stop();
this.postLoadPause = 1000;
this.postLoadTimer;
this.onEnterFrame = updatePreloader;
};
updatePreloader = function () {
var bl = this._parent.getBytesLoaded();
var bt = this._parent.getBytesTotal();
var cf = this._currentframe;
var pcLoaded = Math.floor((100 * bl) / bt);
if (pcLoaded < 10) {
pcLoaded = "0" + pcLoaded;
}
this.loadingBoard.percent.text = pcLoaded;
if (pcLoaded == 100) {
this.loadingBoard.percent.text = "99";
this.gotoAndPlay(2);
delete this.onEnterFrame;
}
};
init();
Symbol 88 MovieClip Frame 32
stop();
this._parent.gotoAndStop("intro");
Symbol 105 MovieClip Frame 1
stop();
Symbol 106 MovieClip Frame 64
stop();
Symbol 114 MovieClip Frame 1
stop();
Symbol 119 MovieClip Frame 1
stop();
Symbol 124 MovieClip Frame 1
stop();
Symbol 127 MovieClip Frame 1
stop();
Symbol 128 MovieClip Frame 1
init = function () {
var getTeamURL = (_root.basepath + "_xml/GetTeamXML.php.xml");
var callback = this;
dataHandler = new XML();
dataHandler.ignoreWhite = true;
dataHandler.onLoad = function (success) {
if (success) {
callback.parseTeamData(this);
}
delete this;
};
dataHandler.load(getTeamURL);
};
parseTeamData = function (teamData) {
var team = new XML(unescape(teamData));
var team = team.childNodes[0].childNodes[0].childNodes[0];
_global.teamData = [];
while (team != null) {
var tName = team.attributes.name.toUpperCase();
var tColour = team.attributes.colour.toUpperCase();
var tID = team.attributes.id;
_global.teamData.push({name:tName, colour:tColour, id:tID});
team = team.nextSibling;
}
};
init();
if (_parent.introViewed) {
gotoAndStop ("end");
}
Symbol 128 MovieClip Frame 44
rocker.player.gotoAndStop("blue");
Instance of Symbol 124 MovieClip in Symbol 128 MovieClip Frame 65
on (release) {
getURL ("http://www.miniclip.com/signup2.htm", "_blank");
}
Instance of Symbol 127 MovieClip in Symbol 128 MovieClip Frame 77
on (release) {
getURL ("http://www.miniclip.com/Homepage.htm", "_blank");
}
Symbol 128 MovieClip Frame 85
init = function () {
stop();
var root = this._parent;
playButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
playButton.onPress = function () {
_global.buttonDownSFX.start();
};
playButton.onRelease = function () {
root.gotoAndStop("team");
};
instructionsButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
instructionsButton.onPress = function () {
_global.buttonDownSFX.start();
};
instructionsButton.onRelease = function () {
root.gotoAndStop("instructions");
};
leaderboardButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
leaderboardButton.onPress = function () {
_global.buttonDownSFX.start();
};
leaderboardButton.onRelease = function () {
root.gotoAndStop("leaderboard");
};
tellFriendButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
tellFriendButton.onPress = function () {
_global.buttonDownSFX.start();
};
tellFriendButton.onRelease = function () {
root.gotoAndStop("fgf");
};
bonusButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
bonusButton.onPress = function () {
_global.buttonDownSFX.start();
};
bonusButton.onRelease = function () {
root.bonusPanel.show();
};
};
init();
if (_parent.introViewed) {
rocker.player.gotoAndStop("blue");
rocker._xscale = (rocker._yscale = 4);
rocker._y = 174.9;
rocker.currStep = 0;
rocker.scales = [3.9, 27.9, 51.9, 76, 100, 103.2, 106.5, 104.3, 102.2, 100];
rocker.yVals = [174.9, 139.75, 104.65, 69.5, 33.9, 29.15, 24.4, 27.55, 30.7, 33.9];
rocker.onEnterFrame = function () {
this._xscale = (this._yscale = this.scales[this.currStep]);
this._y = this.yVals[this.currStep];
if ((++this.currStep) == this.scales.length) {
delete this.onEnterFrame;
}
};
} else {
_parent.introViewed = true;
}
Symbol 145 MovieClip Frame 1
hide = function () {
if (this._parent.gameMC != undefined) {
this._parent.gameMC.state = gameState;
this._parent.gameMC.pitch.bowler.state = bowlerState;
this._parent.gameMC.pitch.batsman.state = batsmanState;
}
disableScrollbar();
this.gotoAndStop("hidden");
};
show = function () {
this.gotoAndStop("showing");
backButton.onRelease = function () {
hide();
};
dummyButton.onRelease = function () {
};
dummyButton.useHandCursor = false;
gameState = this._parent.gameMC.state;
bowlerState = this._parent.gameMC.pitch.bowler.state;
batsmanState = this._parent.gameMC.pitch.batsman.state;
initScrollbar();
};
initScrollbar = function () {
var yMinHandle = -105.2;
var yMaxHandle = 83.4;
var yMinContent = -106.9;
var yMaxContent = -338.3;
handle.onPress = function () {
this.startDrag(false, this._x, yMinHandle, this._x, yMaxHandle);
};
handle.onRelease = (handle.onReleaseOutside = function () {
this.stopDrag();
});
handle.useHandCursor = false;
this.onEnterFrame = function () {
var norm = ((handle._y - yMinHandle) / (yMaxHandle - yMinHandle));
content._y = yMinContent + (norm * (yMaxContent - yMinContent));
};
};
disableScrollbar = function () {
delete this.onEnterFrame;
handle.enabled = false;
};
gameState = 0;
bowlerState = 0;
batsmanState = 0;
this.gotoAndStop("hidden");
Symbol 151 MovieClip Frame 1
marker._visible = false;
Symbol 152 MovieClip Frame 1
marker._visible = false;
Symbol 189 MovieClip Frame 1
stop();
Symbol 192 MovieClip Frame 1
stop();
Symbol 198 MovieClip Frame 1
initBowlerAnimation = function () {
rotationStep = 1;
scaleStep = 5;
counter = 0;
markerBowler._xscale = 5;
markerBowler._yscale = 5;
bowlerGraphic.ball._y = 0;
markerBatsman._xscale = 5;
markerBatsman._yscale = 5;
batsmanGraphic._rotation = 0;
markerMaskBatsman._rotation = 180;
this.onEnterFrame = animateBowler;
};
animateBowler = function () {
markerMaskBowler._rotation = markerMaskBowler._rotation + (rotationStep >> 2);
bowlerGraphic._rotation = bowlerGraphic._rotation + (rotationStep >> 2);
markerBowler._xscale = markerBowler._xscale + scaleStep;
markerBowler._yscale = markerBowler._yscale + scaleStep;
bowlerGraphic.ball._x = (-markerBowler._width) / 2;
var pt = {x:0, y:0};
bowlerGraphic.ball.localToGlobal(pt);
this.globalToLocal(pt);
cursor._x = pt.x;
cursor._y = pt.y;
if (counter == 40) {
rotationStep = -2 * rotationStep;
scaleStep = -scaleStep;
}
if ((++counter) == 90) {
initCursorToBatsman();
}
};
initCursorToBatsman = function () {
var goalX = batsmanGraphic._x;
var goalY = batsmanGraphic._y;
stepX = (goalX - cursor._x) / 30;
stepY = (goalY - cursor._y) / 30;
counter = 0;
this.onEnterFrame = moveCursorToBatsman;
};
moveCursorToBatsman = function () {
cursor._x = cursor._x + stepX;
cursor._y = cursor._y + stepY;
if ((++counter) == 30) {
initBatsmanAnimation();
}
};
initBatsmanAnimation = function () {
rotationStep = -1;
scaleStep = 5;
counter = 0;
markerBatsman._xscale = 5;
markerBatsman._yscale = 5;
markerBowler._xscale = 5;
markerBowler._yscale = 5;
bowlerGraphic._rotation = 0;
markerMaskBowler._rotation = 0;
radar._visible = true;
this.onEnterFrame = animateBatsman;
};
animateBatsman = function () {
markerMaskBatsman._rotation = markerMaskBatsman._rotation + rotationStep;
markerBatsman._xscale = markerBatsman._xscale + scaleStep;
markerBatsman._yscale = markerBatsman._yscale + scaleStep;
batsmanGraphic._rotation = batsmanGraphic._rotation + rotationStep;
var cursorX = (markerBatsman._width / 2);
var pt = {x:cursorX, y:0};
batsmanGraphic.localToGlobal(pt);
this.globalToLocal(pt);
cursor._x = pt.x;
cursor._y = pt.y;
if (counter == 40) {
rotationStep = -2 * rotationStep;
scaleStep = -scaleStep;
}
if ((++counter) == 90) {
initCursorToBowler();
}
};
initCursorToBowler = function () {
radar._visible = false;
var goalX = bowlerGraphic._x;
var goalY = bowlerGraphic._y;
stepX = (goalX - cursor._x) / 30;
stepY = (goalY - cursor._y) / 30;
counter = 0;
this.onEnterFrame = moveCursorToBowler;
};
moveCursorToBowler = function () {
cursor._x = cursor._x + stepX;
cursor._y = cursor._y + stepY;
if ((++counter) == 30) {
initBowlerAnimation();
}
};
initBowlerAnimation();
Instance of Symbol 124 MovieClip in Symbol 205 MovieClip Frame 1
on (release) {
getURL ("http://www.miniclip.com/signup2.htm", "_blank");
}
Instance of Symbol 127 MovieClip in Symbol 205 MovieClip Frame 1
on (release) {
getURL ("http://www.miniclip.com/Homepage.htm", "_blank");
}
Symbol 205 MovieClip Frame 38
stop();
backButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
backButton.onPress = function () {
_global.buttonDownSFX.start();
};
backButton.onRelease = function () {
gotoAndPlay ("out");
};
nextButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
nextButton.onPress = function () {
_global.buttonDownSFX.start();
};
nextButton.onRelease = function () {
nextFrame();
};
Instance of Symbol 124 MovieClip in Symbol 205 MovieClip Frame 71
on (release) {
getURL ("http://www.miniclip.com/cricket.htm", "_blank");
}
Instance of Symbol 127 MovieClip in Symbol 205 MovieClip Frame 83
on (release) {
getURL ("http://www.miniclip.com/Homepage.htm", "_blank");
}
Symbol 205 MovieClip Frame 87
_parent.gotoAndStop("INTRO");
Symbol 207 Button
on (release) {
gotoAndPlay ("instructions");
}
Symbol 210 MovieClip Frame 1
stop();
Symbol 212 MovieClip Frame 80
stop();
Symbol 220 MovieClip Frame 1
stop();
Symbol 221 MovieClip Frame 1
init = function () {
userTeamSet = false;
var root = this._parent;
bonusButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
bonusButton.onPress = function () {
_global.buttonDownSFX.start();
};
bonusButton.onRelease = function () {
root.bonusPanel.show();
};
};
parseTeamData = function (teamData, callback) {
var team = new XML(unescape(teamData));
var team = team.childNodes[0].childNodes[0].childNodes[0];
_global.teamData = [];
while (team != null) {
var tName = team.attributes.name.toUpperCase();
var tColour = team.attributes.colour.toUpperCase();
var tID = team.attributes.id;
_global.teamData.push({name:tName, colour:tColour, id:tID});
team = team.nextSibling;
}
callback.play();
};
layoutTeamButton = function (team, num) {
if (team == undefined) {
return(undefined);
}
var y0 = 28;
var yStep = 40;
var x = (((num % 2) == 0) ? -110 : 34);
var y = (y0 + (yStep * int(num / 2)));
var mc = this.attachMovie("teamButton", "team" + num, num, {_x:x, _y:y});
mc.labelMC.label.text = _global.teamData[num].name;
mc.colour = _global.teamData[num].colour;
mc.id = _global.teamData[num].id;
mc.onRollOver = function () {
_global.buttonOverSFX.start();
this.labelMC.label.textColor = 16763904 /* 0xFFCC00 */;
};
mc.onRollOut = function () {
this.labelMC.label.textColor = 16737792 /* 0xFF6600 */;
};
mc.onDragOut = mc.onRollOut;
mc.onPress = function () {
_global.buttonDownSFX.start();
};
mc.onRelease = function () {
pickTeam(this);
};
};
pickTeam = function (btn) {
if (userTeamSet) {
_global.opponent = btn.labelMC.label.text;
_global.opponentColour = btn.colour;
_global.opponentID = btn.id;
setupMatch();
} else {
_global.team = btn.labelMC.label.text;
_global.teamColour = btn.colour;
_global.teamID = btn.id;
if (_global.teamData.length > 2) {
teamText.gotoAndStop("opponent");
gotoAndStop ("opponentsTeam");
} else if (_global.teamData.length == 2) {
var i = 0;
while (i < _global.teamData.length) {
if (_global.teamData[i].name != btn.labelMC.label.text) {
_global.opponent = _global.teamData[i].name;
_global.opponentColour = _global.teamData[i].colour;
_global.opponentID = _global.teamData[i].id;
setupMatch();
break;
}
i++;
}
}
}
userTeamSet = true;
btn.enabled = false;
};
setupMatch = function () {
for (var i in this) {
if (typeof(this[i]) == "movieclip") {
removeMovieClip(this[i]);
}
}
if (_global.teamData.length == 2) {
gotoAndPlay ("out");
} else {
teamText.gotoAndStop("match");
gotoAndStop ("match");
userTeam.labelMC.label.text = _global.team;
opponentsTeam.labelMC.label.text = _global.opponent;
this.moveOnTimer = setInterval(this, "moveOn", 1400);
}
};
moveOn = function () {
clearInterval(this.moveOnTimer);
gotoAndPlay ("out");
};
init();
rockerL.player.gotoAndStop("blue");
if (_global.gameInited) {
gotoAndPlay ("pickTeam");
}
Instance of Symbol 124 MovieClip in Symbol 221 MovieClip Frame 1
on (release) {
getURL ("http://www.miniclip.com/signup2.htm", "_blank");
}
Instance of Symbol 127 MovieClip "bonusButton" in Symbol 221 MovieClip Frame 1
on (release) {
getURL ("http://www.miniclip.com/Homepage.htm", "_blank");
}
Symbol 221 MovieClip Frame 13
rockerR.player.gotoAndStop("green");
Symbol 221 MovieClip Frame 15
layoutTeamButton(_global.teamData[0], 0);
Symbol 221 MovieClip Frame 17
layoutTeamButton(_global.teamData[1], 1);
Symbol 221 MovieClip Frame 19
layoutTeamButton(_global.teamData[2], 2);
Symbol 221 MovieClip Frame 21
layoutTeamButton(_global.teamData[3], 3);
Symbol 221 MovieClip Frame 23
if (_global.gameInited) {
rockerR.player.gotoAndStop("green");
layoutTeamButton(_global.teamData[0], 0);
layoutTeamButton(_global.teamData[1], 1);
layoutTeamButton(_global.teamData[2], 2);
layoutTeamButton(_global.teamData[3], 3);
}
Symbol 221 MovieClip Frame 25
stop();
Symbol 221 MovieClip Frame 68
this._parent.gotoAndStop("toss");
Symbol 227 MovieClip Frame 1
stop();
Symbol 230 MovieClip Frame 1
stop();
Symbol 260 MovieClip Frame 1
stop();
Symbol 260 MovieClip Frame 2
stop();
Symbol 267 MovieClip Frame 1
stop();
Symbol 270 MovieClip Frame 1
stop();
Symbol 276 MovieClip Frame 14
init = function () {
stop();
headsButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
headsButton.onPress = function () {
_global.buttonDownSFX.start();
};
headsButton.onRelease = function () {
doToss("heads");
};
tailsButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
tailsButton.onPress = function () {
_global.buttonDownSFX.start();
};
tailsButton.onRelease = function () {
doToss("tails");
};
};
doToss = function (userCall) {
userChoice = userCall;
if (System.capabilities.playerType == "External") {
coinToss = userChoice;
} else {
coinToss = ((random(2) == 0) ? "heads" : "tails");
}
play();
};
checkWin = function () {
if (userChoice == coinToss) {
gotoAndPlay ("batOrBowlUser");
} else {
gotoAndPlay ("batOrBowlAuto");
var innings = ((random(2) == 0) ? "bat" : "field");
_global.innings = innings;
this.moveOnTimer = setInterval(this, "moveOn", 3000);
}
};
setBatOrBowlButtons = function () {
batButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
batButton.onPress = function () {
_global.buttonDownSFX.start();
};
batButton.onRelease = function () {
_global.innings = "bat";
gotoAndPlay ("out");
};
bowlButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
bowlButton.onPress = function () {
_global.buttonDownSFX.start();
};
bowlButton.onRelease = function () {
_global.innings = "field";
gotoAndPlay ("out");
};
};
moveOn = function () {
clearInterval(this.moveOnTimer);
gotoAndPlay ("out");
};
init();
Symbol 276 MovieClip Frame 50
hand.coin.gotoAndStop(((coinToss == "heads") ? 1 : 2));
Symbol 276 MovieClip Frame 76
checkWin();
Symbol 276 MovieClip Frame 96
stop();
setBatOrBowlButtons();
Symbol 276 MovieClip Frame 110
gotoAndPlay ("out");
Symbol 276 MovieClip Frame 116
var batBowl = ((_global.innings == "bat") ? "batting" : "bowling");
var opp = _global.opponent.substring(1).toLowerCase();
opp = _global.opponent.charAt(0).toUpperCase() + opp;
tossText.txt.text = ((("Too bad. It looks like " + opp) + " wants you to be ") + batBowl) + " first.";
Symbol 276 MovieClip Frame 121
bowlingLabel._visible = _global.innings == "field";
battingLabel._visible = _global.innings == "bat";
Symbol 276 MovieClip Frame 130
stop();
Symbol 276 MovieClip Frame 163
grounds.bowler.ball._y = 17;
var col = ((_global.innings == "bat") ? (_global.teamColour) : (_global.opponentColour));
grounds.batsman.ani.hat.gotoAndStop(col);
Symbol 276 MovieClip Frame 172
stop();
this._parent.gotoAndStop("game");
Symbol 283 MovieClip Frame 1
stop();
Symbol 306 MovieClip Frame 1
stop();
Symbol 309 MovieClip Frame 1
stop();
Symbol 309 MovieClip Frame 54
inningsOverTxt.text = "END OF INNINGS. CLICK NEXT TO START THE SECOND INNINGS";
var callback = _global.game;
nextButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
nextButton.onPress = function () {
_global.buttonDownSFX.start();
};
nextButton.onRelease = function () {
if (callback.innings == "bat") {
callback.state = 3;
} else {
callback.state = 1;
}
callback.overs = 1;
callback.wickets = 0;
callback.lastInnings = callback.total;
callback.total = 0;
callback.updateScoreboard();
};
var root = this._parent._parent;
bonusButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
bonusButton.onPress = function () {
_global.buttonDownSFX.start();
};
bonusButton.onRelease = function () {
root.bonusPanel.show();
};
Symbol 309 MovieClip Frame 64
var winLose;
if (_global.teamScore > _global.opponentScore) {
_global.winLose = "won";
} else if (_global.teamScore < _global.opponentScore) {
_global.winLose = "lost";
} else if (_global.opponentWickets > _global.teamWickets) {
_global.winLose = "won";
} else if (_global.opponentWickets < _global.teamWickets) {
_global.winLose = "lost";
} else {
_global.winLose = "drew";
}
gameOverTxt.text = ("GAME OVER - YOU " + _global.winLose.toUpperCase()) + "!\nCLICK NEXT TO CONTINUE.";
nextButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
nextButton.onPress = function () {
_global.buttonDownSFX.start();
};
nextButton.onRelease = function () {
this._parent._parent._parent.gotoAndStop("leaderboard");
};
var root = this._parent._parent;
bonusButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
bonusButton.onPress = function () {
_global.buttonDownSFX.start();
};
bonusButton.onRelease = function () {
root.bonusPanel.show();
};
Symbol 312 MovieClip Frame 1
stop();
Symbol 317 MovieClip Frame 1
stop();
Symbol 325 MovieClip Frame 1
stop();
gotoAndStop(_global.teamColour);
Symbol 330 MovieClip Frame 100
this._parent._parent.play();
this._parent._parent.mask.play();
stop();
Symbol 336 MovieClip Frame 78
this._parent._parent.play();
this._parent._parent.mask.play();
stop();
Symbol 344 MovieClip Frame 1
stop();
gotoAndStop(_global.teamColour);
Symbol 348 MovieClip Frame 80
this._parent._parent.play();
this._parent._parent.mask.play();
stop();
Symbol 364 MovieClip Frame 78
this._parent._parent.play();
this._parent._parent.mask.play();
stop();
Symbol 369 MovieClip Frame 78
this._parent._parent.play();
this._parent._parent.mask.play();
stop();
Symbol 370 MovieClip Frame 1
stop();
Symbol 371 MovieClip Frame 1
stop();
content.gotoAndStop("hidden");
showMovie = function (mov) {
content.gotoAndStop(mov);
mask.play();
play();
};
Symbol 371 MovieClip Frame 14
stop();
mask.stop();
Symbol 371 MovieClip Frame 27
gotoAndStop (1);
Symbol 380 MovieClip Frame 1
stop();
_global.game.init(this, _global.innings);
Symbol 385 MovieClip Frame 1
stop();
Symbol 389 MovieClip Frame 1
init = function () {
stopAllSounds();
info_txt.text = ("Your score: " + _global.teamScore) + newline;
info_txt.text = info_txt.text + (("Your wickets: " + _global.teamWickets) + newline);
info_txt.text = info_txt.text + (("Their score: " + _global.opponentScore) + newline);
info_txt.text = info_txt.text + (("Their wickets: " + _global.opponentWickets) + newline);
info_txt.text = info_txt.text + (("You scored: " + _global.userSixes) + " sixes\n");
info_txt.text = info_txt.text + (("You scored: " + _global.userFours) + " fours\n");
info_txt.text = info_txt.text + (("Your strike rate was: " + _global.strikeRate) + newline);
info_txt.text = info_txt.text + (("Your batting rate was: " + _global.battingRate) + newline);
playAgainButton._visible = true;
playAgainButton.onRollOver = function () {
_global.buttonOverSFX.start();
};
playAgainButton.onPress = function () {
_global.buttonDownSFX.start();
};
playAgainButton.onRelease = function () {
this._parent._parent.gotoAndStop("intro");
};
};
init();