Frame 1
ballSpeedX = 0;
ballSpeedY = 0;
blackBallSpeedX = 0;
blackBallSpeedY = 0;
blackBallMc._visible = false;
numOHits = 0;
targetSquare._x = random(200) + 20;
targetSquare._y = random(280) + 20;
nextAction = "None";
accX = 0;
accY = 0;
accZ = 0;
loadMovie ("ball-game-bg.png", "imageLoader");
onEnterFrame = function () {
displayDevice = (((substring(getVersion(), 0, 2)) == "FL") ? "phone" : "pc");
if (displayDevice == "phone") {
loadVariables ("accelerometer://data", _root);
} else {
accX = (-(_root._xmouse - 120)) * 8.25;
accY = (_root._ymouse - 160) * 6.1875;
accZ = 0;
}
ballSpeedX = ballSpeedX + ((-accX) / 400);
ballSpeedY = ballSpeedY + (accY / 400);
ballMc._x = ballMc._x + ballSpeedX;
ballMc._y = ballMc._y + ballSpeedY;
if (ballMc.hitTest(leftEdge) && (ballSpeedX < 0)) {
ballSpeedX = (-ballSpeedX) / 1.15;
ballMc._x = ballMc._width / 2;
}
if (ballMc.hitTest(rightEdge) && (ballSpeedX > 0)) {
ballSpeedX = (-ballSpeedX) / 1.2;
ballMc._x = 240 - (ballMc._width / 2);
}
if (ballMc.hitTest(topEdge) && (ballSpeedY < 0)) {
ballSpeedY = (-ballSpeedY) / 1.2;
ballMc._y = ballMc._height / 2;
}
if (ballMc.hitTest(bottomEdge) && (ballSpeedY > 0)) {
ballSpeedY = (-ballSpeedY) / 1.2;
ballMc._y = 320 - (ballMc._height / 2);
}
if (((ballMc.hitTest(outerLeft) or ballMc.hitTest(outerTop)) or ballMc.hitTest(outerRight)) or ballMc.hitTest(outerBottom)) {
ballMc._x = 120 - (ballMc._width / 2);
ballMc._y = 160 - (ballMc._height / 2);
ballSpeedX = 0;
ballSpeedY = 0;
}
if ((ballMc.hitTest(targetSquare) && (squareStatus == "Ready")) && (nextAction == "None")) {
targetSquare.theSquare.play();
nextAction = "Reposition";
numOHits = numOHits + 1;
squareStatus = "Smashing";
}
if ((nextAction == "Reposition") && (squareStatus == "Ready")) {
targetSquare._x = random(200) + 20;
targetSquare._y = random(280) + 20;
nextAction = "None";
}
earnedPoints.text = "Hits: " + numOHits;
ballMc._x = Math.round(ballMc._x);
ballMc._y = Math.round(ballMc._y);
if (numOHits > 149) {
blackBallMc._visible = true;
blackBallSpeedX = blackBallSpeedX + ((-accX) / 400);
blackBallSpeedY = blackBallSpeedY + (accY / 400);
blackBallMc._x = blackBallMc._x + blackBallSpeedX;
blackBallMc._y = blackBallMc._y + blackBallSpeedY;
if (blackBallMc.hitTest(leftEdge) && (blackBallSpeedX < 0)) {
blackBallSpeedX = (-blackBallSpeedX) / 2;
blackBallMc._x = blackBallMc._width / 2;
}
if (blackBallMc.hitTest(rightEdge) && (blackBallSpeedX > 0)) {
blackBallSpeedX = (-blackBallSpeedX) / 2;
blackBallMc._x = 240 - (blackBallMc._width / 2);
}
if (blackBallMc.hitTest(topEdge) && (blackBallSpeedY < 0)) {
blackBallSpeedY = (-blackBallSpeedY) / 2;
blackBallMc._y = blackBallMc._height / 2;
}
if (blackBallMc.hitTest(bottomEdge) && (blackBallSpeedY > 0)) {
blackBallSpeedY = (-blackBallSpeedY) / 2;
blackBallMc._y = 320 - (blackBallMc._height / 2);
}
if (((blackBallMc.hitTest(outerLeft) or blackBallMc.hitTest(outerTop)) or blackBallMc.hitTest(outerRight)) or blackBallMc.hitTest(outerBottom)) {
blackBallMc._x = 120 - (blackBallMc._width / 2);
blackBallMc._y = 160 - (blackBallMc._height / 2);
blackBallSpeedX = 0;
blackBallSpeedY = 0;
}
if (blackBallMc.hitTest(targetSquare) && (squareStatus == "Ready")) {
targetSquare.theSquare.play();
nextAction = "Reposition";
numOHits = numOHits + 1;
squareStatus = "Smashing";
}
blackBallMc._x = Math.round(blackBallMc._x);
blackBallMc._y = Math.round(blackBallMc._y);
}
};
Symbol 14 MovieClip Frame 1
_root.squareStatus = "Ready";
stop();
Symbol 14 MovieClip Frame 15
_root.squareStatus = "Ready";
Symbol 15 MovieClip Frame 1
stop();