Section 1
//Game (com.novelgames.flashgames.common.Game)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Game extends MovieClip {
public static var gameStage:Stage;
private function getMouseTarget():DisplayObject{
var _local3:int;
var _local1:Point = this.localToGlobal(new Point(mouseX, mouseY));
var _local2:Array = this.getObjectsUnderPoint(_local1);
_local3 = (_local2.length - 1);
while (_local3 >= 0) {
if (!_local2[_local3].parent.mouseEnabled){
} else {
if (((_local2[_local3].parent.parent) && (!(_local2[_local3].parent.parent.mouseChildren)))){
} else {
return (_local2[_local3]);
};
};
_local3--;
};
return (null);
}
public function onRightMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseRightUp"));
}
public function onMiddleMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseMiddleDown"));
}
public function pause():void{
NewTimer.pause();
}
public function onRightMouseDown():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseRightDown"));
}
public function onMiddleMouseUp():void{
var _local1:DisplayObject = getMouseTarget();
if (!_local1){
return;
};
_local1.dispatchEvent(new MouseEvent("mouseMiddleUp"));
}
public function unpause():void{
NewTimer.unpause();
}
}
}//package com.novelgames.flashgames.common
Section 2
//Instructions (com.novelgames.flashgames.common.Instructions)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
public class Instructions extends MovieClip {
public var startButton:SimpleButton;
private var shownFromGame:Boolean;
public function Instructions(_arg1:Boolean=false){
this.shownFromGame = _arg1;
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
}
private function startButtonClicked(_arg1:MouseEvent):void{
if (!shownFromGame){
Object(parent).gotoGamePage();
} else {
Object(parent).hideInstructionsFromGame();
};
}
}
}//package com.novelgames.flashgames.common
Section 3
//InstructionsButton (com.novelgames.flashgames.common.InstructionsButton)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
public class InstructionsButton extends MovieClip {
public function InstructionsButton(){
super();
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, function ():void{
Object(parent.parent).showInstructionsFromGame();
});
}
}
}//package com.novelgames.flashgames.common
Section 4
//MainDevelopment (com.novelgames.flashgames.common.MainDevelopment)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import flash.external.*;
public class MainDevelopment extends MovieClip {
private var titleX:Number;
private var titleY:Number;
private var myScore:int;
private var musicGameSoundChannel:SoundChannel;
private var title:Title;
private var titleIndex:int;
private var instructions:Instructions;
private var game:Game;
private var musicGame:Sound;
public function MainDevelopment(){
super();
checkMute();
try {
ExternalInterface.addCallback("onRightMouseDown", onRightMouseDown);
ExternalInterface.addCallback("onRightMouseUp", onRightMouseUp);
ExternalInterface.addCallback("onMiddleMouseDown", onMiddleMouseDown);
ExternalInterface.addCallback("onMiddleMouseUp", onMiddleMouseUp);
} catch(e) {
};
this.addEventListener(Event.ENTER_FRAME, checkTitle);
}
public function showEnterHighScore(_arg1:int):void{
myScore = _arg1;
}
protected function getMusicGame():Sound{
return (null);
}
public function gotoMoreGamesURL3():void{
navigateToURL(new URLRequest("http://flashgames.info/spiele"), "_blank");
}
public function showHighScores():void{
trace("showHighScores()");
}
private function checkMute():void{
var _local2:SoundTransform;
var _local1:SharedObject = SharedObject.getLocal("mute", "/");
_local1.objectEncoding = ObjectEncoding.AMF0;
if (_local1.data.isMute){
_local2 = new SoundTransform();
_local2.volume = 0;
SoundMixer.soundTransform = _local2;
};
}
public function gotoMoreGamesURL2():void{
navigateToURL(new URLRequest("http://flashgames.info"), "_blank");
}
public function onMiddleMouseDown():void{
if (game){
game.onMiddleMouseDown();
};
}
public function gotoInstructionsPage():void{
removePage();
instructions = new Instructions();
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, titleIndex);
}
public function getScore():int{
return (myScore);
}
public function showInstructionsFromGame():void{
game.pause();
game.visible = false;
instructions = new Instructions(true);
instructions.x = titleX;
instructions.y = titleY;
this.addChildAt(instructions, (titleIndex + 1));
}
private function removePage():void{
if (title){
removeChild(title);
title = null;
};
if (instructions){
removeChild(instructions);
instructions = null;
};
if (game){
removeChild(game);
game = null;
};
if (musicGame){
musicGameSoundChannel.stop();
musicGame = null;
musicGameSoundChannel = null;
};
}
protected function getTitle():Title{
return (null);
}
public function hideInstructionsFromGame():void{
this.removeChild(instructions);
instructions = null;
game.visible = true;
game.unpause();
}
public function gotoMoreGamesURL():void{
navigateToURL(new URLRequest("http://www.flashgames.info"), "_blank");
}
protected function getGame():Game{
return (null);
}
public function onRightMouseDown():void{
if (game){
game.onRightMouseDown();
};
}
public function gotoGamePage():void{
Game.gameStage = stage;
removePage();
game = getGame();
game.x = titleX;
game.y = titleY;
this.addChildAt(game, titleIndex);
musicGame = getMusicGame();
musicGameSoundChannel = musicGame.play(0, int.MAX_VALUE);
}
public function onMiddleMouseUp():void{
if (game){
game.onMiddleMouseUp();
};
}
public function sendeScore():void{
gotoMoreGamesURL3();
}
public function onRightMouseUp():void{
if (game){
game.onRightMouseUp();
};
}
public function gotoTitlePage():void{
removePage();
title = new Title();
title.x = titleX;
title.y = titleY;
this.addChildAt(title, titleIndex);
}
private function checkTitle(_arg1:Event):void{
if (!(title = getTitle())){
return;
};
titleX = title.x;
titleY = title.y;
this.removeEventListener(Event.ENTER_FRAME, checkTitle);
stop();
titleIndex = this.getChildIndex(title);
}
}
}//package com.novelgames.flashgames.common
Section 5
//MuteButton (com.novelgames.flashgames.common.MuteButton)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
public class MuteButton extends MovieClip {
public function MuteButton(){
if (SoundMixer.soundTransform.volume == 0){
showOff();
} else {
showOn();
};
this.addEventListener(MouseEvent.CLICK, buttonClicked);
this.buttonMode = true;
}
private function showOff():void{
gotoAndStop("off");
}
private function showOn():void{
gotoAndStop("on");
}
private function buttonClicked(_arg1:MouseEvent):void{
var _local2:SharedObject = SharedObject.getLocal("mute", "/");
var _local3:SoundTransform = new SoundTransform();
_local2.objectEncoding = ObjectEncoding.AMF0;
if (SoundMixer.soundTransform.volume == 0){
_local2.data.isMute = false;
_local3.volume = 1;
SoundMixer.soundTransform = _local3;
showOn();
} else {
_local2.data.isMute = true;
_local3.volume = 0;
SoundMixer.soundTransform = _local3;
showOff();
};
}
}
}//package com.novelgames.flashgames.common
Section 6
//NewTimer (com.novelgames.flashgames.common.NewTimer)
package com.novelgames.flashgames.common {
import flash.events.*;
import flash.utils.*;
public class NewTimer extends Timer {
private var adjustedStartTime:int;
private var originalRepeatCount:int;
private var originalDelay:int;
private var listener:Function;
private static var pauseTime:int;
private static var paused:Boolean = false;
private static var totalPausedTime:int = 0;
public function NewTimer(_arg1:Number, _arg2:int=0):void{
super(_arg1, _arg2);
originalDelay = _arg1;
originalRepeatCount = _arg2;
}
override public function start():void{
adjustedStartTime = NewTimer.getTimer();
super.start();
}
private function timerEventListener(_arg1:TimerEvent):void{
if (paused){
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
return;
};
if ((NewTimer.getTimer() - adjustedStartTime) >= originalDelay){
adjustedStartTime = NewTimer.getTimer();
if (delay != originalDelay){
stop();
delay = originalDelay;
super.start();
};
listener(_arg1);
} else {
stop();
delay = Math.max((originalDelay - (NewTimer.getTimer() - adjustedStartTime)), 1);
if (originalRepeatCount > 0){
repeatCount++;
};
super.start();
};
}
override public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
if (_arg1 != TimerEvent.TIMER){
super.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5);
return;
};
this.listener = _arg2;
super.addEventListener(_arg1, timerEventListener);
}
public static function unpause():void{
if (!paused){
return;
};
paused = false;
totalPausedTime = (totalPausedTime + (getTimer() - pauseTime));
}
public static function getTimer():int{
if (paused){
return ((pauseTime - totalPausedTime));
};
return ((getTimer() - totalPausedTime));
}
public static function pause():void{
if (paused){
return;
};
paused = true;
pauseTime = getTimer();
}
}
}//package com.novelgames.flashgames.common
Section 7
//Title (com.novelgames.flashgames.common.Title)
package com.novelgames.flashgames.common {
import flash.display.*;
import flash.events.*;
public class Title extends MovieClip {
public var startButton:SimpleButton;
public var logoButton:SimpleButton;
public var moreGamesButton:SimpleButton;
public function Title(){
startButton.addEventListener(MouseEvent.CLICK, startButtonClicked);
moreGamesButton.addEventListener(MouseEvent.CLICK, moreGamesButtonClicked);
logoButton.addEventListener(MouseEvent.CLICK, moreGamesButtonClicked2);
}
private function moreGamesButtonClicked(_arg1:MouseEvent):void{
Object(parent).gotoMoreGamesURL();
}
private function moreGamesButtonClicked2(_arg1:MouseEvent):void{
Object(parent).gotoMoreGamesURL2();
}
private function highScoresButtonClicked(_arg1:MouseEvent):void{
Object(parent).showHighScores();
}
private function startButtonClicked(_arg1:MouseEvent):void{
Object(parent).gotoInstructionsPage();
}
}
}//package com.novelgames.flashgames.common
Section 8
//Arrow (com.novelgames.flashgames.pool.Arrow)
package com.novelgames.flashgames.pool {
import flash.display.*;
public class Arrow extends MovieClip {
private var maskLength:Number;
public var arrowMask:MovieClip;
public function Arrow(){
maskLength = arrowMask.width;
}
public function setRatio(_arg1:Number):void{
arrowMask.x = (maskLength * _arg1);
}
}
}//package com.novelgames.flashgames.pool
Section 9
//Ball (com.novelgames.flashgames.pool.Ball)
package com.novelgames.flashgames.pool {
import flash.display.*;
public class Ball extends MovieClip {
private var cross:MovieClip;
public var directionX:Number;
public var totalFallTime:int;
public var fallRatio:Number;
public var speed:Number;
private var __realX:Number;
private var __realY:Number;
public var speedX:Number;
public var speedY:Number;
public var directionY:Number;
public function Ball(){
speedX = 0;
speedY = 0;
speed = 0;
fallRatio = 0;
totalFallTime = 0;
this.cacheAsBitmap = true;
}
public function get realX():Number{
return (__realX);
}
public function setSpeed(_arg1:Number, _arg2:Number):void{
this.speedX = _arg1;
this.speedY = _arg2;
speed = Math.sqrt(((_arg1 * _arg1) + (_arg2 * _arg2)));
directionX = (_arg1 / speed);
directionY = (_arg2 / speed);
}
public function setSpeedDirection(_arg1:Number, _arg2:Number, _arg3:Number):void{
this.speed = _arg1;
this.directionX = _arg2;
this.directionY = _arg3;
speedX = (_arg1 * _arg2);
speedY = (_arg1 * _arg3);
}
public function get realY():Number{
return (__realY);
}
public function setRed(_arg1:int):void{
switch (_arg1){
case 0:
gotoAndStop("red");
break;
case 1:
gotoAndStop("yellow");
break;
case 2:
gotoAndStop("blue");
break;
case 3:
gotoAndStop("purple");
break;
case 4:
gotoAndStop("green");
break;
case 5:
gotoAndStop("black");
break;
case 6:
gotoAndStop("brown");
break;
case 7:
gotoAndStop("dblue");
break;
case 8:
gotoAndStop("yellow2");
break;
case 9:
gotoAndStop("orange");
break;
default:
gotoAndStop("red");
break;
};
}
public function showCross():void{
if (cross){
return;
};
cross = new BallCross();
this.addChild(cross);
}
public function resetFallTime():void{
this.scaleX = 1;
this.scaleY = 1;
fallRatio = 0;
totalFallTime = 0;
}
public function hideCross():void{
if (!cross){
return;
};
this.removeChild(cross);
cross = null;
}
public function setWhite():void{
gotoAndStop("white");
}
public function addFallTime(_arg1:int):void{
totalFallTime = (totalFallTime + _arg1);
if (totalFallTime >= Config.BALL_HOLETIME){
totalFallTime = Config.BALL_HOLETIME;
};
fallRatio = (totalFallTime / Config.BALL_HOLETIME);
this.scaleX = (1 - fallRatio);
this.scaleY = (1 - fallRatio);
}
private function randomNumber(_arg1:Number, _arg2:Number):Number{
return ((Math.round((Math.random() * (_arg2 - _arg1))) + _arg1));
}
public function set realX(_arg1:Number):void{
__realX = _arg1;
x = _arg1;
}
public function set realY(_arg1:Number):void{
__realY = _arg1;
y = _arg1;
}
}
}//package com.novelgames.flashgames.pool
Section 10
//BallCross (com.novelgames.flashgames.pool.BallCross)
package com.novelgames.flashgames.pool {
import flash.display.*;
public dynamic class BallCross extends MovieClip {
}
}//package com.novelgames.flashgames.pool
Section 11
//Config (com.novelgames.flashgames.pool.Config)
package com.novelgames.flashgames.pool {
public class Config {
public static var LINE_DASHSPACING:Number = 4;
public static var CUE_MAXSPACING:Number = 100;
public static var SCOREPOPUP_NEGATIVEPREFIX:String = "-";
public static var MESSAGE_FINISHEDTIME:int = 1000;
public static var BALL_HOLEDECELERATION:Number = 5000;
public static var CUE_SHOOTTIME:int = 100;
public static var BALL_APPEARTIME:int = 1000;
public static var BALL_MAXSPEED:Number = 1000;
public static var LINE_DASHLENGTH:Number = 3;
public static var SCORE_BALL:int = 1000;
public static var LINE_EXITLENGTH:Number = 40;
public static var MESSAGE_PUTBALLBLINKSHOWTIME:int = 1000;
public static var LINE_ALPHA:Number = 0.6;
public static var SCORE_MULTIPLEBALL:int = 500;
public static var SCOREPOPUP_MOVEHEIGHT:Number = 50;
public static var LINE_TANGENTLENGTH:Number = 50;
public static var BALL_PUTTINGALPHA:Number = 0.5;
public static var SCORE_CONSECUTIVEBALL:int = 1000;
public static var LINE_THICKNESS:Number = 2;
public static var BALL_CUSIONSPEEDLOST:Number = 0.2;
public static var BALL_HOLETIME:int = 100;
public static var SCOREPOPUP_POSITIVEPREFIX:String = "+";
public static var BALL_RADIUS:Number = 10;
public static var BALL_DECELERATION:Number = 100;
public static var SCOREPOPUP_MOVETIME:int = 100;
public static var BALL_TOTAL:int = 10;
public static var FINISHEDWAIT:int = 1000;
public static var SCOREPOPUP_STAYTIME:int = 300;
public static var CUE_PERIOD:Number = 2000;
public static var HOLE_RADIUS:Number = 15;
public static var INITIALWAITTIME:int = 100;
public static var LINE_COLOUR:uint = 13497542;
public static var SCORE_WHITEBALL:int = 3000;
public static var MESSAGE_PUTBALLBLINKHIDETIME:int = 200;
}
}//package com.novelgames.flashgames.pool
Section 12
//Cue (com.novelgames.flashgames.pool.Cue)
package com.novelgames.flashgames.pool {
import flash.display.*;
public class Cue extends MovieClip {
public var cue:MovieClip;
private var x0:Number;
private var x1:Number;
public function Cue(){
x0 = (cue.x - Config.BALL_RADIUS);
x1 = (x0 - Config.CUE_MAXSPACING);
}
public function setRatio(_arg1:Number):void{
cue.x = ((x0 * (1 - _arg1)) + (x1 * _arg1));
}
}
}//package com.novelgames.flashgames.pool
Section 13
//Game (com.novelgames.flashgames.pool.Game)
package com.novelgames.flashgames.pool {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.media.*;
import flash.geom.*;
import flash.utils.*;
import flash.text.*;
public class Game extends Game {
public var message:Message;
public var arrow:Arrow;
public var ballsHolder:MovieClip;
public var tableAreasHolder:MovieClip;
public var scoresHolder:MovieClip;
public var cue:Cue;
private var shrinkedCorners:Array;
private var shrinkedBorders:Array;
private var timer:Timer;
private var balls:Array;
private var startTime:int;
private var shootForceRatio:Number;
public var consecutivePocketsText:TextField;
public var clickDetector:MovieClip;
private var __consecutivePockets:int;
private var tableArea:MovieClip;
private var lastTime:int;
private var soundPocket:Sound;
public var linesHolder:MovieClip;
private var zeit:MyTime;
private var pockets:int;
private var maxCornerX:Number;
private var maxCornerY:Number;
private var soundFinished:Sound;
private var soundCue:Sound;
private var whiteBallPocketed:Boolean;
private var soundBall:Sound;
private var __score:int;
private var holes:Array;
private var borderAreas:Array;
private var corners:Array;
private var whiteBall:Ball;
public var table:MovieClip;
public var scoreText:TextField;
private var minCornerX:Number;
private var minCornerY:Number;
private var shootDX:Number;
private var shootDY:Number;
public function Game(){
score = 0;
consecutivePockets = 0;
zeit = new MyTime();
addChild(zeit);
initializeTable();
timer = new NewTimer(Config.INITIALWAITTIME, 1);
timer.addEventListener(TimerEvent.TIMER, startGame);
timer.start();
soundBall = new SoundBall();
soundCue = new SoundCue();
soundPocket = new SoundPocket();
soundFinished = new SoundFinished();
}
private function moveBalls(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Point;
var _local7:Object;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
_local11 = 0;
while (_local11 < balls.length) {
if (balls[_local11].speed == 0){
} else {
_local2 = balls[_local11].realX;
_local3 = balls[_local11].realY;
_local4 = (balls[_local11].realX + ((balls[_local11].speedX * _arg1) / 1000));
_local5 = (balls[_local11].realY + ((balls[_local11].speedY * _arg1) / 1000));
_local6 = this.localToGlobal(new Point(_local4, _local5));
if (tableArea.hitTestPoint(_local6.x, _local6.y, true)){
_local7 = null;
} else {
_local7 = getHitCusionInfo(_local2, _local3, _local4, _local5);
};
if (!_local7){
balls[_local11].realX = _local4;
balls[_local11].realY = _local5;
} else {
_local8 = (((balls[_local11].speed * _arg1) / 1000) - _local7.length);
if (_local8 < 0){
_local8 = 0;
};
_local9 = Math.sin(_local7.exitAngle);
_local10 = Math.cos(_local7.exitAngle);
balls[_local11].realX = (_local7.x + (_local8 * _local10));
balls[_local11].realY = (_local7.y + (_local8 * _local9));
balls[_local11].setSpeedDirection((balls[_local11].speed * (1 - Config.BALL_CUSIONSPEEDLOST)), _local10, _local9);
};
balls[_local11].speed = (balls[_local11].speed - ((Config.BALL_DECELERATION * _arg1) / 1000));
if (balls[_local11].speed <= 0){
balls[_local11].speed = 0;
balls[_local11].speedX = 0;
balls[_local11].speedY = 0;
} else {
balls[_local11].speedX = (balls[_local11].speed * balls[_local11].directionX);
balls[_local11].speedY = (balls[_local11].speed * balls[_local11].directionY);
};
};
_local11++;
};
}
private function drawHitBorderLines(_arg1:Object):void{
var _local4:Number;
var _local2:Number = Math.atan2((_arg1.y - whiteBall.realY), (_arg1.x - whiteBall.realX));
var _local3:Number = Math.atan2((_arg1.border[1].y - _arg1.border[0].y), (_arg1.border[1].x - _arg1.border[0].x));
linesHolder.graphics.clear();
linesHolder.graphics.lineStyle(Config.LINE_THICKNESS, Config.LINE_COLOUR, Config.LINE_ALPHA);
drawLine(whiteBall.realX, whiteBall.realY, _arg1.x, _arg1.y);
drawBall(_arg1.x, _arg1.y);
if (_local3 < 0){
_local3 = (_local3 + Math.PI);
};
_local4 = ((_local3 * 2) - _local2);
drawLine(_arg1.x, _arg1.y, (_arg1.x + (Math.cos(_local4) * Config.LINE_EXITLENGTH)), (_arg1.y + (Math.sin(_local4) * Config.LINE_EXITLENGTH)));
}
private function showPlayAgain(_arg1:TimerEvent):void{
Object(parent).showEnterHighScore((score / zeit.getTime()));
clickDetector.visible = false;
message.showPlayAgain();
}
private function initializeTable():void{
var _local1:Point;
var _local2:int;
holes = new Array();
_local2 = 0;
while (true) {
if (!table[("hole" + _local2)]){
break;
};
_local1 = new Point(table[("hole" + _local2)].x, table[("hole" + _local2)].y);
_local1 = table.localToGlobal(_local1);
holes.push(_local1);
_local2++;
};
corners = new Array();
_local2 = 0;
while (true) {
if (!table[("corner" + _local2)]){
break;
};
_local1 = new Point(table[("corner" + _local2)].x, table[("corner" + _local2)].y);
_local1 = table.localToGlobal(_local1);
corners.push(_local1);
_local2++;
};
createShrinkedCorners();
}
private function onPutBallMouseMove(_arg1:MouseEvent):void{
_arg1.updateAfterEvent();
whiteBall.realX = mouseX;
whiteBall.realY = mouseY;
updateBallPuttable();
}
public function set consecutivePockets(_arg1:int):void{
__consecutivePockets = _arg1;
consecutivePocketsText.text = _arg1.toString();
}
public function set score(_arg1:int):void{
__score = _arg1;
scoreText.text = _arg1.toString();
}
private function getHitBorderInfo():Object{
var _local3:Point;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:int;
var _local1:Object = new Object();
var _local2:Array = [new Point(whiteBall.realX, whiteBall.realY), new Point(mouseX, mouseY)];
_local1.length = Number.MAX_VALUE;
_local7 = 0;
while (_local7 < shrinkedBorders.length) {
_local3 = getIntersection(_local2, shrinkedBorders[_local7]);
if (!_local3){
} else {
if (((!((shrinkedBorders[_local7][0].x == shrinkedBorders[_local7][1].x))) && ((((_local3.x - shrinkedBorders[_local7][0].x) * (_local3.x - shrinkedBorders[_local7][1].x)) > 0)))){
} else {
if (((!((shrinkedBorders[_local7][0].y == shrinkedBorders[_local7][1].y))) && ((((_local3.y - shrinkedBorders[_local7][0].y) * (_local3.y - shrinkedBorders[_local7][1].y)) > 0)))){
} else {
if (((whiteBall.realX - _local3.x) * (whiteBall.realX - mouseX)) < 0){
} else {
if (((whiteBall.realY - _local3.y) * (whiteBall.realY - mouseY)) < 0){
} else {
if (!getIsInsideOfBorder(whiteBall.realX, whiteBall.realY, shrinkedBorders[_local7])){
} else {
_local4 = (_local3.x - whiteBall.realX);
_local5 = (_local3.y - whiteBall.realY);
_local6 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
if (_local6 < _local1.length){
_local1.border = shrinkedBorders[_local7];
_local1.length = _local6;
_local1.x = _local3.x;
_local1.y = _local3.y;
};
};
};
};
};
};
};
_local7++;
};
return (_local1);
}
private function onMoveTime(_arg1:TimerEvent):void{
var _local4:int;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - lastTime);
_arg1.updateAfterEvent();
_local4 = 0;
while (_local4 < _local3) {
moveBalls(1);
checkBounce();
checkPockets(1);
if (checkMoveFinished()){
break;
};
_local4++;
};
lastTime = _local2;
if (_local4 < _local3){
timer.stop();
timer = new NewTimer(Config.FINISHEDWAIT, 1);
timer.addEventListener(TimerEvent.TIMER, moveFinished);
timer.start();
};
}
private function getIsInsideOfBorder(_arg1:Number, _arg2:Number, _arg3:Array):Boolean{
var _local6:Number;
var _local4:Point = _arg3[0];
var _local5:Point = _arg3[1];
_local6 = (Math.atan2((_local5.y - _arg2), (_local5.x - _arg1)) - Math.atan2((_local4.y - _arg2), (_local4.x - _arg1)));
if (_local6 < -(Math.PI)){
_local6 = (_local6 + (Math.PI * 2));
} else {
if (_local6 > Math.PI){
_local6 = (_local6 - (Math.PI * 2));
};
};
return ((_local6 > 0));
}
private function onAppearTime(_arg1:TimerEvent):void{
var _local4:int;
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.BALL_APPEARTIME);
if (_local3 > 1){
_local3 = 1;
};
_local4 = 0;
while (_local4 < balls.length) {
balls[_local4].alpha = _local3;
_local4++;
};
if (_local3 >= 1){
timer.stop();
startPutBall();
};
}
private function drawHitBallLines(_arg1:Object):void{
var _local2:Number = ((_arg1.x + _arg1.ball.realX) / 2);
var _local3:Number = ((_arg1.y + _arg1.ball.realY) / 2);
var _local4:Number = (_arg1.ball.realX - _arg1.x);
var _local5:Number = (_arg1.ball.realY - _arg1.y);
var _local6:Number = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
var _local7:Number = -(_local5);
var _local8:Number = _local4;
var _local9:Number = _local6;
linesHolder.graphics.clear();
linesHolder.graphics.lineStyle(Config.LINE_THICKNESS, Config.LINE_COLOUR, Config.LINE_ALPHA);
drawLine(whiteBall.realX, whiteBall.realY, _arg1.x, _arg1.y);
drawBall(_arg1.x, _arg1.y);
drawLine(_local2, _local3, (_local2 + ((Config.LINE_EXITLENGTH * _local4) / _local6)), (_local3 + ((Config.LINE_EXITLENGTH * _local5) / _local6)));
drawLine((_local2 - (((Config.LINE_TANGENTLENGTH * _local7) / _local9) / 2)), (_local3 - (((Config.LINE_TANGENTLENGTH * _local8) / _local9) / 2)), (_local2 + (((Config.LINE_TANGENTLENGTH * _local7) / _local9) / 2)), (_local3 + (((Config.LINE_TANGENTLENGTH * _local8) / _local9) / 2)));
}
private function getHitPoint(_arg1:Array, _arg2:Number, _arg3:Number):Point{
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local4:Number = _arg1[0].x;
var _local5:Number = _arg1[0].y;
var _local6:Number = _arg1[1].x;
var _local7:Number = _arg1[1].y;
_local8 = (((_local6 - _local4) * (_local6 - _local4)) + ((_local7 - _local5) * (_local7 - _local5)));
if (_local8 == 0){
return (null);
};
if (_local6 == _local4){
_local12 = _local4;
_local11 = (((4 * Config.BALL_RADIUS) * Config.BALL_RADIUS) - ((_local12 - _arg2) * (_local12 - _arg2)));
if (_local11 < 0){
return (null);
};
if (_local7 > _local5){
_local13 = (_arg3 - Math.sqrt(_local11));
} else {
_local13 = (_arg3 + Math.sqrt(_local11));
};
if (((_local13 - _local5) * (_local13 - _local7)) > 0){
return (null);
};
return (new Point(_local12, _local13));
};
_local9 = (2 * ((((-(_arg2) * (_local6 - _local4)) * (_local6 - _local4)) - ((_local4 * (_local7 - _local5)) * (_local7 - _local5))) + (((_local6 - _local4) * (_local7 - _local5)) * (_local5 - _arg3))));
_local10 = ((((((((_local6 - _local4) * (_local6 - _local4)) * _arg2) * _arg2) + ((((_local7 - _local5) * (_local7 - _local5)) * _local4) * _local4)) - ((((2 * (_local6 - _local4)) * (_local7 - _local5)) * (_local5 - _arg3)) * _local4)) + ((((_local5 - _arg3) * (_local5 - _arg3)) * (_local6 - _local4)) * (_local6 - _local4))) - ((((4 * Config.BALL_RADIUS) * Config.BALL_RADIUS) * (_local6 - _local4)) * (_local6 - _local4)));
_local11 = ((_local9 * _local9) - ((4 * _local8) * _local10));
if (_local11 < 0){
return (null);
};
if (_local6 > _local4){
_local12 = ((-(_local9) - Math.sqrt(_local11)) / (2 * _local8));
} else {
_local12 = ((-(_local9) + Math.sqrt(_local11)) / (2 * _local8));
};
if (((_local12 - _local4) * (_local12 - _local6)) > 0){
return (null);
};
_local13 = ((((_local12 - _local4) / (_local6 - _local4)) * (_local7 - _local5)) + _local5);
return (new Point(_local12, _local13));
}
private function drawLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
var _local9:int;
var _local5:Number = (_arg3 - _arg1);
var _local6:Number = (_arg4 - _arg2);
var _local7:Number = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
var _local8:int = Math.floor((_local7 / (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)));
_local9 = 0;
while (_local9 < _local8) {
linesHolder.graphics.moveTo((_arg1 + (((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) * _local5) / _local7)), (_arg2 + (((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) * _local6) / _local7)));
linesHolder.graphics.lineTo((_arg1 + ((((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) + Config.LINE_DASHLENGTH) * _local5) / _local7)), (_arg2 + ((((_local9 * (Config.LINE_DASHLENGTH + Config.LINE_DASHSPACING)) + Config.LINE_DASHLENGTH) * _local6) / _local7)));
_local9++;
};
}
private function performBounce(_arg1:Ball, _arg2:Ball):void{
var _local3:Number = Math.atan2((_arg1.realY - _arg2.realY), (_arg1.realX - _arg2.realX));
var _local4:Number = Math.cos(_local3);
var _local5:Number = Math.sin(_local3);
var _local6:Number = ((_arg1.speedX * _local5) - (_arg1.speedY * _local4));
var _local7:Number = ((_arg1.speedX * _local4) + (_arg1.speedY * _local5));
var _local8:Number = ((_arg2.speedX * _local5) - (_arg2.speedY * _local4));
var _local9:Number = ((_arg2.speedX * _local4) + (_arg2.speedY * _local5));
if ((((_local7 > 0)) && ((_local9 < 0)))){
return;
};
_arg1.setSpeed(((_local6 * _local5) + (_local9 * _local4)), ((-(_local6) * _local4) + (_local9 * _local5)));
_arg2.setSpeed(((_local8 * _local5) + (_local7 * _local4)), ((-(_local8) * _local4) + (_local7 * _local5)));
soundBall.play();
}
private function drawBall(_arg1:Number, _arg2:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local3:Number = Math.tan((Math.PI / 8));
linesHolder.graphics.moveTo((_arg1 + Config.BALL_RADIUS), _arg2);
_local9 = 0;
while (_local9 < 8) {
_local4 = (((_local9 + 1) * Math.PI) / 4);
_local7 = (_arg1 + (Config.BALL_RADIUS * Math.cos(_local4)));
_local8 = (_arg2 + (Config.BALL_RADIUS * Math.sin(_local4)));
_local5 = (_local7 + ((Config.BALL_RADIUS * _local3) * Math.sin(_local4)));
_local6 = (_local8 - ((Config.BALL_RADIUS * _local3) * Math.cos(_local4)));
linesHolder.graphics.curveTo(_local5, _local6, _local7, _local8);
_local9++;
};
}
private function moveFinished(_arg1:TimerEvent):void{
if (whiteBallPocketed){
consecutivePockets = 0;
whiteBall.resetFallTime();
balls.push(whiteBall);
if (balls.length == 1){
showFinished();
} else {
startPutBall();
};
} else {
if (pockets == 0){
consecutivePockets = 0;
};
if (balls.length == 1){
showFinished();
} else {
startAim();
};
};
}
private function onAimClick(_arg1:MouseEvent):void{
var _local2:Number;
shootDX = (mouseX - whiteBall.realX);
shootDY = (mouseY - whiteBall.realY);
if ((((shootDX == 0)) && ((shootDY == 0)))){
return;
};
this.removeEventListener(MouseEvent.MOUSE_MOVE, onAimMouseMove);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onAimClick);
clickDetector.buttonMode = false;
_local2 = Math.sqrt(((shootDX * shootDX) + (shootDY * shootDY)));
shootDX = (shootDX / _local2);
shootDY = (shootDY / _local2);
arrow.x = (whiteBall.realX + (Config.BALL_RADIUS * shootDX));
arrow.y = (whiteBall.realY + (Config.BALL_RADIUS * shootDY));
arrow.rotation = cue.rotation;
arrow.setRatio(0);
arrow.visible = true;
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onSetForceClick);
clickDetector.buttonMode = true;
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onSetForceTime);
timer.start();
}
private function addScore(_arg1:int, _arg2:Number, _arg3:Number):void{
var _local4:ScorePopup = new ScorePopup();
this.score = (this.score + _arg1);
_local4.initialize(_arg2, _arg3, _arg1);
scoresHolder.addChild(_local4);
}
private function startGame(_arg1:TimerEvent):void{
createBalls();
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onAppearTime);
timer.start();
}
private function checkPockets(_arg1:int):void{
var _local2:Number;
var _local3:Number;
var _local4:int;
var _local5:int;
_local4 = 0;
while (_local4 < balls.length) {
if ((((balls[_local4].speed == 0)) && ((balls[_local4].totalFallTime == 0)))){
} else {
_local5 = 0;
while (_local5 < holes.length) {
_local2 = (balls[_local4].realX - holes[_local5].x);
_local3 = (balls[_local4].realY - holes[_local5].y);
if (((_local2 * _local2) + (_local3 * _local3)) < (Config.HOLE_RADIUS * Config.HOLE_RADIUS)){
break;
};
_local5++;
};
if (_local5 < holes.length){
balls[_local4].addFallTime(_arg1);
balls[_local4].speed = (balls[_local4].speed - ((Config.BALL_HOLEDECELERATION * _arg1) / 1000));
if (balls[_local4].speed <= 0){
balls[_local4].speed = 0;
balls[_local4].speedX = 0;
balls[_local4].speedY = 0;
};
if (balls[_local4].fallRatio == 1){
if (balls[_local4] == whiteBall){
addScore(-(Config.SCORE_WHITEBALL), holes[_local5].x, holes[_local5].y);
whiteBallPocketed = true;
} else {
addScore(((Config.SCORE_BALL + (Config.SCORE_CONSECUTIVEBALL * consecutivePockets)) + (Config.SCORE_MULTIPLEBALL * pockets)), holes[_local5].x, holes[_local5].y);
pockets++;
consecutivePockets++;
};
balls.splice(_local4, 1);
_local4--;
soundPocket.play();
};
} else {
balls[_local4].resetFallTime();
};
};
_local4++;
};
}
private function onShootTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.CUE_SHOOTTIME);
if (_local3 > 1){
_local3 = 1;
};
_arg1.updateAfterEvent();
cue.setRatio((1 - _local3));
if (_local3 >= 1){
timer.stop();
soundCue.play();
cue.visible = false;
whiteBall.setSpeed(((Config.BALL_MAXSPEED * shootForceRatio) * shootDX), ((Config.BALL_MAXSPEED * shootForceRatio) * shootDY));
lastTime = _local2;
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onMoveTime);
timer.start();
};
}
private function startAim():void{
pockets = 0;
whiteBallPocketed = false;
whiteBall.alpha = 1;
cue.x = whiteBall.x;
cue.y = whiteBall.y;
cue.setRatio(0);
updateAim();
this.addEventListener(MouseEvent.MOUSE_MOVE, onAimMouseMove);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onAimClick);
clickDetector.buttonMode = true;
}
public function get consecutivePockets():int{
return (__consecutivePockets);
}
private function onSetForceTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = (((_local2 - startTime) % Config.CUE_PERIOD) / Config.CUE_PERIOD);
shootForceRatio = ((_local3 < 0.5)) ? (_local3 * 2) : (2 - (_local3 * 2));
_arg1.updateAfterEvent();
cue.setRatio(shootForceRatio);
arrow.setRatio(shootForceRatio);
}
public function get score():int{
return (__score);
}
private function createShrinkedCorners():void{
var _local2:Point;
var _local3:Point;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:Array;
var _local9:MovieClip;
var _local10:int;
var _local1:Array = new Array();
_local10 = 0;
while (_local10 < corners.length) {
_local2 = corners[_local10].clone();
_local3 = corners[((_local10 + 1) % corners.length)].clone();
_local4 = (_local3.x - _local2.x);
_local5 = (_local3.y - _local2.y);
_local6 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
_local2.x = (_local2.x - ((Config.BALL_RADIUS * _local5) / _local6));
_local2.y = (_local2.y + ((Config.BALL_RADIUS * _local4) / _local6));
_local3.x = (_local3.x - ((Config.BALL_RADIUS * _local5) / _local6));
_local3.y = (_local3.y + ((Config.BALL_RADIUS * _local4) / _local6));
_local1.push([_local2, _local3]);
_local10++;
};
shrinkedCorners = new Array();
_local10 = 0;
while (_local10 < _local1.length) {
_local7 = _local1[(((_local10 + _local1.length) - 1) % _local1.length)];
_local8 = _local1[_local10];
shrinkedCorners.push(getIntersection(_local7, _local8));
_local10++;
};
shrinkedBorders = new Array();
minCornerX = Number.MAX_VALUE;
maxCornerX = Number.MIN_VALUE;
minCornerY = Number.MAX_VALUE;
maxCornerY = Number.MIN_VALUE;
borderAreas = new Array();
tableArea = new MovieClip();
tableArea.graphics.beginFill(0, 0);
tableArea.graphics.moveTo(shrinkedCorners[0].x, shrinkedCorners[0].y);
_local10 = 0;
while (_local10 < shrinkedCorners.length) {
if (shrinkedCorners[_local10].x < minCornerX){
minCornerX = shrinkedCorners[_local10].x;
};
if (shrinkedCorners[_local10].x > maxCornerX){
maxCornerX = shrinkedCorners[_local10].x;
};
if (shrinkedCorners[_local10].y < minCornerY){
minCornerY = shrinkedCorners[_local10].y;
};
if (shrinkedCorners[_local10].y > maxCornerY){
maxCornerY = shrinkedCorners[_local10].y;
};
shrinkedBorders.push([shrinkedCorners[_local10], shrinkedCorners[((_local10 + 1) % shrinkedCorners.length)]]);
tableArea.graphics.lineTo(shrinkedCorners[((_local10 + 1) % shrinkedCorners.length)].x, shrinkedCorners[((_local10 + 1) % shrinkedCorners.length)].y);
_local9 = new MovieClip();
_local9.graphics.beginFill(0, 0);
_local9.graphics.moveTo(corners[_local10].x, corners[_local10].y);
_local9.graphics.lineTo(corners[((_local10 + 1) % corners.length)].x, corners[((_local10 + 1) % corners.length)].y);
_local9.graphics.lineTo(shrinkedCorners[((_local10 + 1) % shrinkedCorners.length)].x, shrinkedCorners[((_local10 + 1) % shrinkedCorners.length)].y);
_local9.graphics.lineTo(shrinkedCorners[_local10].x, shrinkedCorners[_local10].y);
_local9.graphics.lineTo(corners[_local10].x, corners[_local10].y);
_local9.graphics.endFill();
borderAreas.push(_local9);
tableAreasHolder.addChild(_local9);
_local10++;
};
tableAreasHolder.addChild(tableArea);
}
private function checkMoveFinished():Boolean{
var _local1:int;
_local1 = 0;
while (_local1 < balls.length) {
if (balls[_local1].speed > 0){
return (false);
};
if (balls[_local1].fallRatio > 0){
return (false);
};
_local1++;
};
return (true);
}
private function updateBallPuttable():void{
if (!getCanPutBall(whiteBall.realX, whiteBall.realY)){
whiteBall.showCross();
} else {
whiteBall.hideCross();
};
}
private function checkBounce():void{
var _local1:Number;
var _local2:Number;
var _local3:int;
var _local4:int;
_local3 = 0;
while (_local3 < balls.length) {
_local4 = (_local3 + 1);
while (_local4 < balls.length) {
if ((((balls[_local3].speed == 0)) && ((balls[_local4].speed == 0)))){
} else {
_local1 = (balls[_local3].realX - balls[_local4].realX);
_local2 = (balls[_local3].realY - balls[_local4].realY);
if (((_local1 * _local1) + (_local2 * _local2)) >= ((Config.BALL_RADIUS * Config.BALL_RADIUS) * 4)){
} else {
performBounce(balls[_local3], balls[_local4]);
};
};
_local4++;
};
_local3++;
};
}
private function showFinished():void{
zeit.stopTimer();
message.showFinished();
soundFinished.play();
timer = new NewTimer(Config.MESSAGE_FINISHEDTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showPlayAgain);
timer.start();
}
private function getCanPutBall(_arg1:Number, _arg2:Number):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:Point;
var _local6:int;
_local6 = 0;
while (_local6 < holes.length) {
_local3 = (holes[_local6].x - _arg1);
_local4 = (holes[_local6].y - _arg2);
if (((_local3 * _local3) + (_local4 * _local4)) < (Config.HOLE_RADIUS * Config.HOLE_RADIUS)){
return (false);
};
_local6++;
};
_local6 = 0;
while (_local6 < balls.length) {
if (balls[_local6] == whiteBall){
} else {
_local3 = (balls[_local6].realX - _arg1);
_local4 = (balls[_local6].realY - _arg2);
if (((_local3 * _local3) + (_local4 * _local4)) < ((Config.BALL_RADIUS * Config.BALL_RADIUS) * 4)){
return (false);
};
};
_local6++;
};
_local5 = this.localToGlobal(new Point(_arg1, _arg2));
return (tableArea.hitTestPoint(_local5.x, _local5.y, true));
}
private function createBalls():void{
var _local1:Ball;
var _local2:Point;
var _local3:int;
balls = new Array();
_local3 = 0;
while (_local3 < Config.BALL_TOTAL) {
_local1 = new Ball();
_local1.setRed(_local3);
_local2 = getPossibleBallPosition();
_local1.realX = _local2.x;
_local1.realY = _local2.y;
_local1.alpha = 0;
ballsHolder.addChild(_local1);
balls.push(_local1);
_local3++;
};
whiteBall = new Ball();
whiteBall.setWhite();
whiteBall.visible = false;
ballsHolder.addChild(whiteBall);
balls.push(whiteBall);
}
private function getHitCusionInfo(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Object{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local11:int;
var _local5:Point = this.localToGlobal(new Point(_arg3, _arg4));
var _local10:Object;
_local11 = 0;
while (_local11 < borderAreas.length) {
if (!borderAreas[_local11].hitTestPoint(_local5.x, _local5.y, true)){
} else {
_local6 = Math.atan2((_arg4 - _arg2), (_arg3 - _arg1));
_local7 = Math.atan2((shrinkedBorders[_local11][1].y - shrinkedBorders[_local11][0].y), (shrinkedBorders[_local11][1].x - shrinkedBorders[_local11][0].x));
_local8 = ((_local7 * 2) - _local6);
_local9 = (_local8 - _local7);
if (_local9 > (Math.PI * 2)){
_local9 = (_local9 - (Math.PI * 2));
} else {
if (_local9 < 0){
_local9 = (_local9 + (Math.PI * 2));
};
};
if (_local9 >= Math.PI){
} else {
_local10 = new Object();
_local10.border = shrinkedBorders[_local11];
_local10.length = 0;
_local10.x = _arg1;
_local10.y = _arg2;
_local10.exitAngle = _local8;
break;
};
};
_local11++;
};
return (_local10);
}
private function updateAim():void{
var _local1:Object;
var _local2:Object;
var _local3:Number;
var _local4:Number;
if ((((mouseX == whiteBall.realX)) && ((mouseY == whiteBall.realY)))){
linesHolder.graphics.clear();
cue.visible = false;
return;
};
_local1 = getHitBorderInfo();
_local2 = getHitBallInfo(_local1.x, _local1.y);
if (!_local2){
drawHitBorderLines(_local1);
} else {
drawHitBallLines(_local2);
};
_local3 = (mouseX - whiteBall.realX);
_local4 = (mouseY - whiteBall.realY);
cue.rotation = ((Math.atan2(_local4, _local3) * 180) / Math.PI);
cue.visible = true;
}
private function onSetForceClick(_arg1:MouseEvent):void{
timer.stop();
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onSetForceClick);
clickDetector.buttonMode = false;
linesHolder.graphics.clear();
arrow.visible = false;
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onShootTime);
timer.start();
}
private function getHitBallInfo(_arg1:Number, _arg2:Number):Object{
var _local5:Point;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local3:Object;
var _local4:Array = [new Point(whiteBall.realX, whiteBall.realY), new Point(_arg1, _arg2)];
_local9 = 0;
while (_local9 < balls.length) {
if (balls[_local9] == whiteBall){
} else {
_local5 = getHitPoint(_local4, balls[_local9].realX, balls[_local9].realY);
if (!_local5){
} else {
_local6 = (_local5.x - whiteBall.realX);
_local7 = (_local5.y - whiteBall.realY);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
if (((!(_local3)) || ((_local8 < _local3.length)))){
_local3 = new Object();
_local3.ball = balls[_local9];
_local3.length = _local8;
_local3.x = _local5.x;
_local3.y = _local5.y;
};
};
};
_local9++;
};
return (_local3);
}
private function getPossibleBallPosition():Point{
var _local1:Number;
var _local2:Number;
while (true) {
_local1 = ((minCornerX + Config.BALL_RADIUS) + (Math.random() * ((maxCornerX - minCornerX) - (Config.BALL_RADIUS * 2))));
_local2 = ((minCornerY + Config.BALL_RADIUS) + (Math.random() * ((maxCornerY - minCornerY) - (Config.BALL_RADIUS * 2))));
if (getCanPutBall(_local1, _local2)){
break;
};
};
return (new Point(_local1, _local2));
}
private function onAimMouseMove(_arg1:MouseEvent):void{
_arg1.updateAfterEvent();
updateAim();
}
private function startPutBall():void{
whiteBall.alpha = Config.BALL_PUTTINGALPHA;
whiteBall.visible = true;
whiteBall.realX = mouseX;
whiteBall.realY = mouseY;
updateBallPuttable();
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onPutBallClick);
clickDetector.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_MOVE, onPutBallMouseMove);
message.showPut();
}
private function onPutBallClick(_arg1:MouseEvent):void{
if (!getCanPutBall(whiteBall.x, whiteBall.y)){
return;
};
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onPutBallClick);
clickDetector.buttonMode = false;
this.removeEventListener(MouseEvent.MOUSE_MOVE, onPutBallMouseMove);
message.hide();
startAim();
}
private function getIntersection(_arg1:Array, _arg2:Array):Point{
var _local11:Number;
var _local12:Number;
var _local3:Number = _arg1[0].x;
var _local4:Number = _arg1[0].y;
var _local5:Number = _arg1[1].x;
var _local6:Number = _arg1[1].y;
var _local7:Number = _arg2[0].x;
var _local8:Number = _arg2[0].y;
var _local9:Number = _arg2[1].x;
var _local10:Number = _arg2[1].y;
if ((((_local9 - _local7) * (_local6 - _local4)) - ((_local5 - _local3) * (_local10 - _local8))) == 0){
return (null);
};
_local11 = (((((((_local9 - _local7) * (_local6 - _local4)) * _local3) - (((_local9 - _local7) * (_local5 - _local3)) * _local4)) - (((_local5 - _local3) * (_local10 - _local8)) * _local7)) + (((_local5 - _local3) * (_local9 - _local7)) * _local8)) / (((_local9 - _local7) * (_local6 - _local4)) - ((_local5 - _local3) * (_local10 - _local8))));
_local12 = (((((((_local9 - _local7) * (_local6 - _local4)) * _local8) - (((_local6 - _local4) * (_local10 - _local8)) * _local7)) - (((_local5 - _local3) * (_local10 - _local8)) * _local4)) + (((_local10 - _local8) * (_local6 - _local4)) * _local3)) / (((_local9 - _local7) * (_local6 - _local4)) - ((_local5 - _local3) * (_local10 - _local8))));
return (new Point(_local11, _local12));
}
}
}//package com.novelgames.flashgames.pool
Section 14
//Main (com.novelgames.flashgames.pool.Main)
package com.novelgames.flashgames.pool {
import com.novelgames.flashgames.common.*;
import flash.media.*;
import mochi.as3.*;
public class Main extends MainDevelopment {
private var mochiClip:Background;
public var title:Title;
public function Main(){
stage.showDefaultContextMenu = false;
showMochi();
}
override protected function getMusicGame():Sound{
return (new MusicGame());
}
private function showMochi():void{
mochiClip = new Background();
addChild(mochiClip);
MochiAd.showPreGameAd({clip:mochiClip, id:"385cd8bde86cac9f", res:"600x400", ad_finished:this.adFinished});
}
override protected function getTitle():Title{
return (title);
}
function adFinished():void{
removeChild(mochiClip);
}
override protected function getGame():Game{
return (new Game());
}
}
}//package com.novelgames.flashgames.pool
Section 15
//Message (com.novelgames.flashgames.pool.Message)
package com.novelgames.flashgames.pool {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
import flash.text.*;
public class Message extends MovieClip {
private var putBlinkTimer:Timer;
public function Message(){
stop();
visible = false;
}
private function moreButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoMoreGamesURL3();
}
public function hide():void{
if (putBlinkTimer){
putBlinkTimer.stop();
putBlinkTimer = null;
};
visible = false;
}
private function playAgainButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoGamePage();
}
private function logoButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoMoreGamesURL2();
}
public function showPlayAgain():void{
var _local1:MessagePlayAgain = new MessagePlayAgain();
_local1.playAgainButton.addEventListener(MouseEvent.CLICK, playAgainButtonClicked);
_local1.homeButton.addEventListener(MouseEvent.CLICK, homeButtonClicked);
_local1.logoButton.addEventListener(MouseEvent.CLICK, logoButtonClicked);
_local1.moreGames.addEventListener(MouseEvent.CLICK, moreButtonClicked);
_local1.punkteText.text = Object(parent.parent).getScore();
this.addChild(_local1);
}
public function showPut():void{
gotoAndStop("put");
visible = true;
putBlinkTimer = new NewTimer(Config.MESSAGE_PUTBALLBLINKSHOWTIME, 1);
putBlinkTimer.addEventListener(TimerEvent.TIMER, onPutBlinkTime);
putBlinkTimer.start();
}
private function homeButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).sendeScore();
}
private function onPutBlinkTime(_arg1:TimerEvent):void{
visible = !(visible);
putBlinkTimer = new NewTimer((visible) ? Config.MESSAGE_PUTBALLBLINKSHOWTIME : Config.MESSAGE_PUTBALLBLINKHIDETIME, 1);
putBlinkTimer.addEventListener(TimerEvent.TIMER, onPutBlinkTime);
putBlinkTimer.start();
}
public function showFinished():void{
gotoAndStop("finished");
visible = true;
}
}
}//package com.novelgames.flashgames.pool
Section 16
//MessagePlayAgain (com.novelgames.flashgames.pool.MessagePlayAgain)
package com.novelgames.flashgames.pool {
import flash.display.*;
import flash.text.*;
public dynamic class MessagePlayAgain extends MovieClip {
public var punkteText:TextField;
public var homeButton:SimpleButton;
public var moreGames:SimpleButton;
public var logoButton:SimpleButton;
public var playAgainButton:SimpleButton;
}
}//package com.novelgames.flashgames.pool
Section 17
//MusicGame (com.novelgames.flashgames.pool.MusicGame)
package com.novelgames.flashgames.pool {
import flash.media.*;
public dynamic class MusicGame extends Sound {
}
}//package com.novelgames.flashgames.pool
Section 18
//MyTime (com.novelgames.flashgames.pool.MyTime)
package com.novelgames.flashgames.pool {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.text.*;
public class MyTime extends MovieClip {
public var consecutivePocketsText:TextField;
public var txt_sec:TextField;
public var txt_min:TextField;
private var sec:int;// = 0
private var min:int;// = 0
private var zeit:Timer;
public function MyTime(){
zeit = new Timer(1000, 0);
super();
zeit.addEventListener(TimerEvent.TIMER, updateTime);
zeit.start();
}
public function getTime():int{
return (((min * 60) + sec));
}
public function stopTimer():void{
zeit.stop();
}
public function startTimer():void{
zeit.start();
}
private function updateTime(_arg1:TimerEvent):void{
if (sec < 59){
sec++;
} else {
min++;
sec = 0;
};
if (min < 10){
txt_min.text = ("0" + String(min));
} else {
txt_min.text = String(min);
};
if (sec < 10){
txt_sec.text = ("0" + String(sec));
} else {
txt_sec.text = String(sec);
};
}
}
}//package com.novelgames.flashgames.pool
Section 19
//ScorePopup (com.novelgames.flashgames.pool.ScorePopup)
package com.novelgames.flashgames.pool {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
import flash.text.*;
public class ScorePopup extends MovieClip {
private var timer:Timer;
private var originalY:Number;
private var startTime:int;
public var scoreText:TextField;
private function stayFinished(_arg1:TimerEvent):void{
parent.removeChild(this);
}
public function initialize(_arg1:Number, _arg2:Number, _arg3:int):void{
this.x = _arg1;
this.y = _arg2;
originalY = _arg2;
if (_arg3 > 0){
scoreText.text = (Config.SCOREPOPUP_POSITIVEPREFIX + _arg3);
} else {
scoreText.text = (Config.SCOREPOPUP_NEGATIVEPREFIX + -(_arg3));
};
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onMoveTime);
timer.start();
}
private function onMoveTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.SCOREPOPUP_MOVETIME);
if (_local3 > 1){
_local3 = 1;
};
_arg1.updateAfterEvent();
y = (originalY - (Config.SCOREPOPUP_MOVEHEIGHT * Math.sin((_local3 * Math.PI))));
if (_local3 >= 1){
timer.stop();
timer = new NewTimer(Config.SCOREPOPUP_STAYTIME, 1);
timer.addEventListener(TimerEvent.TIMER, stayFinished);
timer.start();
};
}
}
}//package com.novelgames.flashgames.pool
Section 20
//SoundBall (com.novelgames.flashgames.pool.SoundBall)
package com.novelgames.flashgames.pool {
import flash.media.*;
public dynamic class SoundBall extends Sound {
}
}//package com.novelgames.flashgames.pool
Section 21
//SoundCue (com.novelgames.flashgames.pool.SoundCue)
package com.novelgames.flashgames.pool {
import flash.media.*;
public dynamic class SoundCue extends Sound {
}
}//package com.novelgames.flashgames.pool
Section 22
//SoundFinished (com.novelgames.flashgames.pool.SoundFinished)
package com.novelgames.flashgames.pool {
import flash.media.*;
public dynamic class SoundFinished extends Sound {
}
}//package com.novelgames.flashgames.pool
Section 23
//SoundPocket (com.novelgames.flashgames.pool.SoundPocket)
package com.novelgames.flashgames.pool {
import flash.media.*;
public dynamic class SoundPocket extends Sound {
}
}//package com.novelgames.flashgames.pool
Section 24
//MochiAd (mochi.as3.MochiAd)
package mochi.as3 {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.system.*;
import flash.net.*;
public class MochiAd {
public static function getVersion():String{
return ("3.0 as3");
}
public static function showClickAwayAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, regpt:"o", method:"showClickAwayAd", res:"300x250", no_bg:true, ad_started:function ():void{
}, ad_finished:function ():void{
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
var sendHostProgress:Boolean;
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
_local3 = true;
chk.started = getTimer();
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (this.root == null){
_local3 = true;
};
if (_local3){
delete this.onEnterFrame;
};
};
doOnEnterFrame(chk);
}
public static function _isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function _allowDomains(_arg1:String):String{
var _local2:String = _arg1.split("/")[2].split(":")[0];
if (Security.sandboxType == "application"){
return (_local2);
};
Security.allowDomain("*");
Security.allowDomain(_local2);
Security.allowInsecureDomain("*");
Security.allowInsecureDomain(_local2);
return (_local2);
}
public static function unload(_arg1:Object):Boolean{
if (((_arg1.clip) && (_arg1.clip._mochiad))){
_arg1 = _arg1.clip;
};
if (_arg1.origFrameRate != undefined){
_arg1.stage.frameRate = _arg1.origFrameRate;
};
if (!_arg1._mochiad){
return (false);
};
if (_arg1._mochiad._containerLCName != undefined){
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
};
if (_arg1._mochiad.onUnload){
_arg1._mochiad.onUnload();
};
delete _arg1._mochiad_loaded;
delete _arg1._mochiad;
return (true);
}
public static function showInterLevelAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd", ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
options.ad_finished();
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
mc.unloadAd = function ():void{
MochiAd.unload(clip);
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = (_arg1 - 250);
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
chk["onEnterFrame"] = function ():void{
var _local4:Number;
if (!this.parent){
delete this.onEnterFrame;
delete this.fadeFunction;
return;
};
var _local1:Object = this.parent._mochiad_ctr;
var _local2:Number = (getTimer() - this.started);
var _local3:Boolean;
if (!chk.showing){
_local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local4 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if (_local2 > chk.ad_timeout){
options.ad_failed();
_local3 = true;
};
};
};
if (_local2 > chk.ad_msec){
_local3 = true;
};
if (_local3){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
var _local4:String;
var _local5:Array;
var _local6:Number;
var _local7:Array;
var _local3:Object = {};
for (_local4 in _arg2) {
_local3[_local4] = _arg2[_local4];
};
if (_arg1){
for (_local4 in _arg1) {
_local3[_local4] = _arg1[_local4];
};
};
if (_local3.clip == undefined){
throw (new Error("MochiAd is missing the 'clip' parameter. This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
};
_arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
if (_arg1){
_local5 = _arg1.split("&");
_local6 = 0;
while (_local6 < _local5.length) {
_local7 = _local5[_local6].split("=");
_local3[unescape(_local7[0])] = unescape(_local7[1]);
_local6++;
};
};
if (_local3.id == "test"){
trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
};
return (_local3);
}
public static function _cleanup(_arg1:Object):void{
var k:String;
var lc:LocalConnection;
var f:Function;
var mc = _arg1;
if (("lc" in mc)){
lc = mc.lc;
f = function ():void{
try {
lc.client = null;
lc.close();
} catch(e:Error) {
};
};
setTimeout(f, 0);
};
var idx:Number = DisplayObjectContainer(mc).numChildren;
while (idx > 0) {
idx = (idx - 1);
DisplayObjectContainer(mc).removeChildAt(idx);
};
for (k in mc) {
delete mc[k];
};
}
public static function load(_arg1:Object):MovieClip{
var clip:Object;
var k:String;
var server:String;
var hostname:String;
var lc:LocalConnection;
var name:String;
var loader:Loader;
var g:Function;
var req:URLRequest;
var v:Object;
var options = _arg1;
var DEFAULTS:Object = {server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, DEFAULTS);
options.swfv = 9;
options.mav = MochiAd.getVersion();
clip = options.clip;
if (!MochiAd._isNetworkAvailable()){
return (null);
};
try {
if (clip._mochiad_loaded){
return (null);
};
} catch(e:Error) {
throw (new Error("MochiAd requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
var depth:Number = options.depth;
delete options.depth;
var mc:MovieClip = createEmptyMovieClip(clip, "_mochiad", depth);
var wh:Array = MochiAd._getRes(options, clip);
options.res = ((wh[0] + "x") + wh[1]);
options.server = (options.server + options.id);
delete options.id;
clip._mochiad_loaded = true;
if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
options.as3_swf = clip.loaderInfo.loaderURL;
} else {
trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
};
var lv:URLVariables = new URLVariables();
for (k in options) {
v = options[k];
if (!(v is Function)){
lv[k] = v;
};
};
server = lv.server;
delete lv.server;
hostname = _allowDomains(server);
lc = new LocalConnection();
lc.client = mc;
name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
lc.allowDomain("*", "localhost");
lc.allowInsecureDomain("*", "localhost");
lc.connect(name);
mc.lc = lc;
mc.lcName = name;
lv.lc = name;
lv.st = getTimer();
loader = new Loader();
g = function (_arg1:Object):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
MochiAd.unload(clip);
};
loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
req.contentType = "application/x-www-form-urlencoded";
req.method = URLRequestMethod.POST;
req.data = lv;
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:IOErrorEvent):void{
trace("[MochiAds] Blocked URL");
});
loader.load(req);
mc.addChild(loader);
mc._mochiad_ctr = loader;
return (mc);
}
public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
if (typeof(_arg1[_local4[_local5]]) == "function"){
return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
};
return (undefined);
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
var _local4:MovieClip = new MovieClip();
if (((false) && (_arg3))){
_arg1.addChildAt(_local4, _arg3);
} else {
_arg1.addChild(_local4);
};
_arg1[_arg2] = _local4;
_local4["_name"] = _arg2;
return (_local4);
}
public static function _getRes(_arg1:Object, _arg2:Object):Array{
var _local6:Array;
var _local3:Object = _arg2.getBounds(_arg2.root);
var _local4:Number = 0;
var _local5:Number = 0;
if (typeof(_arg1.res) != "undefined"){
_local6 = _arg1.res.split("x");
_local4 = parseFloat(_local6[0]);
_local5 = parseFloat(_local6[1]);
} else {
_local4 = (_local3.xMax - _local3.xMin);
_local5 = (_local3.yMax - _local3.yMin);
};
if ((((_local4 == 0)) || ((_local5 == 0)))){
_local4 = _arg2.stage.stageWidth;
_local5 = _arg2.stage.stageHeight;
};
return ([_local4, _local5]);
}
public static function adShowing(_arg1:Object):void{
_arg1.origFrameRate = _arg1.stage.frameRate;
_arg1.stage.frameRate = 30;
}
public static function getValue(_arg1:Object, _arg2:String):Object{
var _local3:Array = _arg2.split(".");
var _local4:Number = 0;
while (_local4 < (_local3.length - 1)) {
if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
return (undefined);
};
_arg1 = _arg1[_local3[_local4]];
_local4++;
};
return (_arg1[_local3[_local4]]);
}
public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
var _local4:Object;
var _local5:Object;
switch (_arg3.id){
case "setValue":
MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
break;
case "getValue":
_local4 = MochiAd.getValue(_arg1, _arg3.objectName);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
break;
case "runMethod":
_local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
_arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
break;
default:
trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
};
}
public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Array = _arg2.split(".");
var _local5:Number = 0;
while (_local5 < (_local4.length - 1)) {
if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
return;
};
_arg1 = _arg1[_local4[_local5]];
_local5++;
};
_arg1[_local4[_local5]] = _arg3;
}
public static function showPreGameAd(_arg1:Object):void{
var clip:Object;
var mc:MovieClip;
var chk:MovieClip;
var complete:Boolean;
var unloaded:Boolean;
var sendHostProgress:Boolean;
var fn:Function;
var r:MovieClip;
var options = _arg1;
var DEFAULTS:Object = {ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:0xFF8A00, background:16777161, outline:13994812, no_progress_bar:false, ad_started:function ():void{
if ((this.clip is MovieClip)){
this.clip.stop();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_finished:function ():void{
if ((this.clip is MovieClip)){
this.clip.play();
} else {
throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip. If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
};
}, ad_loaded:function (_arg1:Number, _arg2:Number):void{
}, ad_failed:function ():void{
trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
}, ad_skipped:function ():void{
}, ad_progress:function (_arg1:Number):void{
}};
options = MochiAd._parseOptions(options, DEFAULTS);
if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
options.ad_started();
fn = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
return;
};
clip = options.clip;
var ad_msec:Number = 11000;
var ad_timeout:Number = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time:Number = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)){
options.ad_failed();
options.ad_finished();
return;
};
options.ad_started();
mc = clip._mochiad;
mc["onUnload"] = function ():void{
MochiAd._cleanup(mc);
var fn:Function = function ():void{
options.ad_finished();
};
setTimeout(fn, 100);
};
var wh:Array = MochiAd._getRes(options, clip);
var w:Number = wh[0];
var h:Number = wh[1];
mc.x = (w * 0.5);
mc.y = (h * 0.5);
chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
chk.x = (w * -0.5);
chk.y = (h * -0.5);
var bar:MovieClip = createEmptyMovieClip(chk, "_mochiad_bar", 4);
if (options.no_progress_bar){
bar.visible = false;
delete options.no_progress_bar;
} else {
bar.x = 10;
bar.y = (h - 20);
};
var bar_color:Number = options.color;
delete options.color;
var bar_background:Number = options.background;
delete options.background;
var bar_outline:Number = options.outline;
delete options.outline;
var backing_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 1);
var backing:Object = backing_mc.graphics;
backing.beginFill(bar_background);
backing.moveTo(0, 0);
backing.lineTo((w - 20), 0);
backing.lineTo((w - 20), 10);
backing.lineTo(0, 10);
backing.lineTo(0, 0);
backing.endFill();
var inside_mc:MovieClip = createEmptyMovieClip(bar, "_inside", 2);
var inside:Object = inside_mc.graphics;
inside.beginFill(bar_color);
inside.moveTo(0, 0);
inside.lineTo((w - 20), 0);
inside.lineTo((w - 20), 10);
inside.lineTo(0, 10);
inside.lineTo(0, 0);
inside.endFill();
inside_mc.scaleX = 0;
var outline_mc:MovieClip = createEmptyMovieClip(bar, "_outline", 3);
var outline:Object = outline_mc.graphics;
outline.lineStyle(0, bar_outline, 100);
outline.moveTo(0, 0);
outline.lineTo((w - 20), 0);
outline.lineTo((w - 20), 10);
outline.lineTo(0, 10);
outline.lineTo(0, 0);
chk.ad_msec = ad_msec;
chk.ad_timeout = ad_timeout;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function ():void{
var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
if (_local1 > 0){
this.parent.alpha = (_local1 * 0.01);
} else {
MochiAd.unload(clip);
delete this["onEnterFrame"];
};
};
complete = false;
unloaded = false;
var f:Function = function (_arg1:Event):void{
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
complete = true;
if (unloaded){
MochiAd.unload(clip);
};
};
clip.loaderInfo.addEventListener(Event.COMPLETE, f);
if ((clip.root is MovieClip)){
r = (clip.root as MovieClip);
if (r.framesLoaded >= r.totalFrames){
complete = true;
};
};
mc.unloadAd = function ():void{
unloaded = true;
if (complete){
MochiAd.unload(clip);
};
};
mc.adLoaded = options.ad_loaded;
mc.adSkipped = options.ad_skipped;
mc.adjustProgress = function (_arg1:Number):void{
var _local2:Object = mc._mochiad_wait;
_local2.server_control = true;
_local2.showing = true;
_local2.started = getTimer();
_local2.ad_msec = _arg1;
};
mc.rpc = function (_arg1:Number, _arg2:Object):void{
MochiAd.rpc(clip, _arg1, _arg2);
};
mc.rpcTestFn = function (_arg1:String):Object{
trace(("[MOCHIAD rpcTestFn] " + _arg1));
return (_arg1);
};
mc.regContLC = function (_arg1:String):void{
mc._containerLCName = _arg1;
};
sendHostProgress = false;
mc.sendHostLoadProgress = function (_arg1:String):void{
sendHostProgress = true;
};
chk["onEnterFrame"] = function ():void{
var _local11:Number;
if (((!(this.parent)) || (!(this.parent.parent)))){
delete this["onEnterFrame"];
return;
};
var _local1:Object = this.parent.parent.root;
var _local2:Object = this.parent._mochiad_ctr;
var _local3:Number = (getTimer() - this.started);
var _local4:Boolean;
var _local5:Number = _local1.loaderInfo.bytesTotal;
var _local6:Number = _local1.loaderInfo.bytesLoaded;
if (complete){
_local6 = Math.max(1, _local6);
_local5 = _local6;
};
var _local7:Number = ((100 * _local6) / _local5);
var _local8:Number = ((100 * _local3) / chk.ad_msec);
var _local9:Object = this._mochiad_bar._inside;
var _local10:Number = Math.min(100, Math.min(((_local7) || (0)), _local8));
_local10 = Math.max(this.last_pcnt, _local10);
this.last_pcnt = _local10;
_local9.scaleX = (_local10 * 0.01);
options.ad_progress(_local10);
if (sendHostProgress){
clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {id:"hostLoadPcnt", pcnt:_local7});
if (_local7 == 100){
sendHostProgress = false;
};
};
if (!chk.showing){
_local11 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
if (_local11 > 0){
chk.showing = true;
chk.started = getTimer();
MochiAd.adShowing(clip);
} else {
if ((((_local3 > chk.ad_timeout)) && ((_local7 == 100)))){
options.ad_failed();
_local4 = true;
};
};
};
if (_local3 > chk.ad_msec){
_local4 = true;
};
if (((complete) && (_local4))){
if (this.server_control){
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
};
};
};
doOnEnterFrame(chk);
}
public static function showPreloaderAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
MochiAd.showPreGameAd(_arg1);
}
public static function showTimedAd(_arg1:Object):void{
trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
MochiAd.showInterLevelAd(_arg1);
}
public static function doOnEnterFrame(_arg1:MovieClip):void{
var mc = _arg1;
var f:Function = function (_arg1:Object):void{
if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
mc.onEnterFrame();
} else {
_arg1.target.removeEventListener(_arg1.type, arguments.callee);
};
};
mc.addEventListener(Event.ENTER_FRAME, f);
}
}
}//package mochi.as3
Section 25
//Background (Background)
package {
import flash.display.*;
public dynamic class Background extends MovieClip {
}
}//package