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
//Ball (com.novelgames.flashgames.mathlines.Ball)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.text.*;
public class Ball extends MovieClip {
public var dropDistance:Number;
public var combo:int;
public var ballIndex:int;
public var numberText:MovieClip;
public var pathInfoIndex:int;
public var adjustDistance:Number;
public var isDropping:Boolean;
public var targetDistance:Number;
public var directionX:Number;
public var insertX:Number;
public var insertY:Number;
public var directionY:Number;
public var lineIndex:int;
public var shouldCheckDestroyAfterDrop:Boolean;
public var shouldDestroy:Boolean;
public var number:int;
public var startTime:int;
public var colourIndex:int;
public var isAdjusting:Boolean;
public var distance:Number;
public var isInserting:Boolean;
public function Ball(){
isInserting = false;
isAdjusting = false;
shouldDestroy = false;
stop();
}
public function doAdjustDistance(_arg1:int):void{
var _local2:Number = ((_arg1 - startTime) / Config.BALL_INSERTTIME);
if (_local2 > 1){
_local2 = 1;
};
distance = ((adjustDistance * (1 - _local2)) + (targetDistance * _local2));
if (_local2 >= 1){
isAdjusting = false;
};
}
public function initialize(_arg1:Boolean):void{
number = (Config.BALL_MINNUMBER + Math.floor((Math.random() * ((Config.BALL_MAXNUMBER - Config.BALL_MINNUMBER) + 1))));
showNumber(number);
if (_arg1){
showCorrectColour();
} else {
showRandomColour();
};
}
public function doDrop(_arg1:int):Boolean{
var _local2:int = (_arg1 - startTime);
var _local3:Number = (((Config.BALL_DROPACCELERATION * _local2) * _local2) / 2000000);
distance = (dropDistance - _local3);
if (distance <= targetDistance){
distance = targetDistance;
isDropping = false;
return (true);
};
return (false);
}
public function showRandomColour():void{
colourIndex = Math.floor((Math.random() * Config.BALL_COLOURS));
showColour(colourIndex);
}
public function doInsert(_arg1:Number, _arg2:Number, _arg3:int):Boolean{
var _local4:Number = ((_arg3 - startTime) / Config.BALL_INSERTTIME);
if (_local4 > 1){
_local4 = 1;
};
this.x = ((insertX * (1 - _local4)) + (_arg1 * _local4));
this.y = ((insertY * (1 - _local4)) + (_arg2 * _local4));
if (_local4 >= 1){
isInserting = false;
return (true);
};
return (false);
}
public function showNumber(_arg1:int):void{
this.number = _arg1;
numberText.numberText.text = _arg1.toString();
}
public function showColour(_arg1:int):void{
this.colourIndex = _arg1;
gotoAndStop((_arg1 + 1));
}
public function showCorrectColour():void{
var _local1:int = Math.ceil(((Config.BALL_MINNUMBER + Config.BALL_MAXNUMBER) / 2));
if (number <= _local1){
colourIndex = (number - Config.BALL_MINNUMBER);
} else {
colourIndex = (Config.BALL_MAXNUMBER - number);
};
showColour(colourIndex);
}
}
}//package com.novelgames.flashgames.mathlines
Section 9
//Cannon (com.novelgames.flashgames.mathlines.Cannon)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public class Cannon extends MovieClip {
public var highlight:MovieClip;
public var backBall:Ball;
public var frontBall:Ball;
public function Cannon(){
frontBall.visible = false;
backBall.visible = false;
}
public function generateNewBall(_arg1:Boolean, _arg2:Array):void{
var _local5:int;
var _local6:int;
var _local3:Array = new Array();
var _local4:Array = new Array();
frontBall.showNumber(backBall.number);
frontBall.showColour(backBall.colourIndex);
_local5 = 0;
while (_local5 < _arg2.length) {
_local3[_local5] = ((Config.BALL_MAXNUMBER + Config.BALL_MINNUMBER) - _arg2[_local5]);
_local5++;
};
_local4 = _arg2.concat();
_local6 = (_local4.length - 1);
_local5 = 0;
while (_local5 < _local3.length) {
while (_local6 >= 0) {
if (_local3[_local5] >= _local4[_local6]){
break;
};
_local6--;
};
if ((((_local6 < 0)) || ((_local3[_local5] > _local4[_local6])))){
_local4.splice((_local6 + 1), 0, _local3[_local5]);
};
_local5++;
};
backBall.showNumber(_local4[Math.floor((Math.random() * _local4.length))]);
if (_arg1){
backBall.showCorrectColour();
} else {
backBall.showRandomColour();
};
}
public function switchBalls():void{
var _local1:int = backBall.number;
var _local2:int = backBall.colourIndex;
backBall.showNumber(frontBall.number);
backBall.showColour(frontBall.colourIndex);
frontBall.showNumber(_local1);
frontBall.showColour(_local2);
}
public function updateRotation(_arg1:Number):void{
rotation = _arg1;
frontBall.rotation = -(_arg1);
backBall.rotation = -(_arg1);
highlight.rotation = -(_arg1);
}
public function generateBalls(_arg1:Boolean):void{
frontBall.initialize(_arg1);
backBall.initialize(_arg1);
frontBall.visible = true;
backBall.visible = true;
}
}
}//package com.novelgames.flashgames.mathlines
Section 10
//Coin (com.novelgames.flashgames.mathlines.Coin)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
public class Coin extends MovieClip {
public var coin:MovieClip;
private var timer:Timer;
private var startTime:int;
public function Coin(){
stop();
}
public function initialize(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();
}
public function uninitialize():void{
timer.stop();
}
private function onTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
var _local3:Number = (((_local2 - startTime) % Config.COIN_PERIOD) / Config.COIN_PERIOD);
_arg1.updateAfterEvent();
coin.gotoAndStop((Math.floor((_local3 * coin.totalFrames)) + 1));
}
}
}//package com.novelgames.flashgames.mathlines
Section 11
//Config (com.novelgames.flashgames.mathlines.Config)
package com.novelgames.flashgames.mathlines {
public class Config {
public static var LEVEL_NOOFBALLSINCREASE:int = 10;
public static var STAR_APPEARTIME:int = 500;
public static var EXPLODE_TIME:int = 200;
public static var LEVEL_SCOREINCREASE:int = 100;
public static var SCOREPOPUP_PREFIX:String = "+";
public static var MESSAGE_GAMEOVERTIME:int = 1000;
public static var BALL_MINX:Number = 0;
public static var BALL_MINY:Number = 0;
public static var SCORE_BALL:int = 10;
public static var BALL_DROPACCELERATION:Number = 1000;
public static var EXPLODE_DISTANCE:Number = 20;
public static var STAR_SPACING:Number = BALL_SIZE;
public static var LEVEL_INITIALNOOFBALLS:int = 50;
public static var BALL_MINNUMBER:int = 1;
public static var COIN_PERIOD:int = 400;
public static var BALL_SIZE:Number = 28;
public static var BALL_INITIALSPEED:Number = 1000;
public static var SCOREPOPUP_MOVEHEIGHT:int = 30;
public static var LEVEL_NOOFLAYOUTS:int = 3;
public static var BALL_INSERTTIME:int = 100;
public static var BALL_COLOURS:int = 5;
public static var BALL_INITIALPERCENT:Number = 30;
public static var LEVEL_INITIALSCORE:int = 1000;
public static var BALL_MAXNUMBER:int = 9;
public static var BALL_SHOOTSPEED:Number = 700;
public static var COIN_APPEARTIME:int = 30000;
public static var LEVEL_BALLSPEEDINCREASE:Number = 2;
public static var COIN_EFFECTTIME:int = 20000;
public static var BALL_MAXX:Number = 600;
public static var BALL_MAXY:Number = 400;
public static var COIN_APPEARINTERVAL:int = 60000;
public static var MESSAGE_LEVELTIME:int = 1000;
public static var EXPLODE_NOOFPIECES:int = 8;
public static var LEVEL_INITIALBALLSPEED:Number = 10;
public static var SCORE_COMBO:int = 50;
public static var SCOREPOPUP_MOVETIME:int = 200;
public static var STAR_APPEARINTERVAL:int = 50;
public static var SCOREPOPUP_STAYTIME:int = 500;
public static var MESSAGE_LEVELCLEARTIME:int = 2000;
public static var COIN_SIZE:Number = 32;
public static var BALL_LOSESPEED:int = 1500;
public static var SCORE_STAR:int = 50;
}
}//package com.novelgames.flashgames.mathlines
Section 12
//Explode (com.novelgames.flashgames.mathlines.Explode)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.utils.*;
public class Explode extends MovieClip {
private var timer:Timer;
private var pieceDirectionYs:Array;
private var startTime:int;
private var pieceDirectionXs:Array;
private var pieces:Array;
private function onTime(_arg1:TimerEvent):void{
var _local4:Number;
var _local5:int;
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((_local2 - startTime) / Config.EXPLODE_TIME);
if (_local3 > 1){
_local3 = 1;
};
_arg1.updateAfterEvent();
_local4 = (_local3 * Config.EXPLODE_DISTANCE);
_local5 = 0;
while (_local5 < pieces.length) {
pieces[_local5].x = (pieceDirectionXs[_local5] * _local4);
pieces[_local5].y = (pieceDirectionYs[_local5] * _local4);
pieces[_local5].alpha = (1 - _local3);
_local5++;
};
if (_local3 >= 1){
timer.stop();
parent.removeChild(this);
};
}
public function initialize(_arg1:Number, _arg2:Number):void{
var _local3:ExplodePiece;
var _local4:int;
this.x = _arg1;
this.y = _arg2;
pieces = new Array();
pieceDirectionXs = new Array();
pieceDirectionYs = new Array();
_local4 = 0;
while (_local4 < Config.EXPLODE_NOOFPIECES) {
_local3 = new ExplodePiece();
_local3.rotation = ((360 * _local4) / Config.EXPLODE_NOOFPIECES);
pieceDirectionXs[_local4] = Math.cos((((Math.PI * 2) * _local4) / Config.EXPLODE_NOOFPIECES));
pieceDirectionYs[_local4] = Math.sin((((Math.PI * 2) * _local4) / Config.EXPLODE_NOOFPIECES));
this.addChild(_local3);
pieces.push(_local3);
_local4++;
};
startTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();
}
}
}//package com.novelgames.flashgames.mathlines
Section 13
//ExplodePiece (com.novelgames.flashgames.mathlines.ExplodePiece)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class ExplodePiece extends MovieClip {
}
}//package com.novelgames.flashgames.mathlines
Section 14
//Game (com.novelgames.flashgames.mathlines.Game)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.events.*;
import com.novelgames.flashgames.common.*;
import flash.media.*;
import flash.geom.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
public class Game extends Game {
private var soundStar:Sound;
public var message:Message;
public var ballMasksHolder:MovieClip;
private var soundGameOver:Sound;
public var levelLayoutHolder:MovieClip;
public var ballsHolder:MovieClip;
private var layout:MovieClip;
public var scoresHolder:MovieClip;
private var existingNumbers:Array;
private var timer:Timer;
private var soundCoin:Sound;
public var coinsHolder:MovieClip;
private var startTime:int;
private var soundShoot:Sound;
private var balls:Array;
private var noOfBallsPerLine:int;
private var totalDistance:Number;
private var pathInfos:Array;
private var stars:Array;
private var levelBallSpeed:Number;
public var starsHolder:MovieClip;
public var clickDetector:MovieClip;
private var coinAppearTime:int;
private var levelScore:int;
private var maxDistance:Number;
private var lastTime:int;
private var level:int;
private var coin:Coin;
private var ballEnds:Array;
private var levelNoOfBalls:int;
private var hasCorrectColours:Boolean;
private var soundLevelClear:Sound;
private var checkDestroyBalls:Array;
private var winDistances:Array;
private var shootingBalls:Array;
private var __score:int;
private var hasCorrectColoursEndTime:int;
private var checkBothSides:Array;
private var coinPositions:Array;
public var scoreText:TextField;
private var noOfCreatedBalls:Array;
private var soundDestroy:Sound;
private var cannon:Cannon;
public var explodesHolder:MovieClip;
private var coinDisappearTime:int;
public function Game(){
score = 0;
soundStar = new SoundStar();
soundShoot = new SoundShoot();
soundDestroy = new SoundDestroy();
soundLevelClear = new SoundLevelClear();
soundGameOver = new SoundGameOver();
soundCoin = new SoundCoin();
startLevel(1);
}
private function showGameOver(_arg1:TimerEvent):void{
Object(parent).showEnterHighScore(score);
message.showPlayAgain();
}
private function updateBalls(_arg1:int, _arg2:int):void{
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:Ball;
var _local7:int;
var _local8:Number;
var _local9:int;
if (ballEnds[_arg1] < 0){
_local3 = Math.ceil((-(ballEnds[_arg1]) / Config.BALL_SIZE));
} else {
_local3 = 0;
};
if (_local3 >= noOfBallsPerLine){
return;
};
_local4 = (_local3 * Config.BALL_SIZE);
while (true) {
if (noOfCreatedBalls[_arg1] >= noOfBallsPerLine){
break;
};
if (balls[_arg1].length > 0){
_local3 = (balls[_arg1][0].ballIndex - 1);
if (((balls[_arg1][0].isDropping) || (balls[_arg1][0].isAdjusting))){
_local5 = (balls[_arg1][0].targetDistance - Config.BALL_SIZE);
} else {
_local5 = (balls[_arg1][0].distance - Config.BALL_SIZE);
};
if (_local5 < _local4){
break;
};
} else {
_local3 = (noOfBallsPerLine - 1);
_local5 = (_local3 * Config.BALL_SIZE);
};
var _local10 = noOfCreatedBalls;
var _local11 = _arg1;
var _local12 = (_local10[_local11] + 1);
_local10[_local11] = _local12;
_local6 = new Ball();
_local6.initialize(hasCorrectColours);
_local6.lineIndex = _arg1;
_local6.ballIndex = _local3;
_local6.distance = _local5;
balls[_arg1].unshift(_local6);
ballsHolder.addChild(_local6);
};
_local7 = 0;
_local9 = 0;
while (_local9 < balls[_arg1].length) {
if (balls[_arg1][_local9].isAdjusting){
balls[_arg1][_local9].doAdjustDistance(_arg2);
};
if (balls[_arg1][_local9].isDropping){
if (balls[_arg1][_local9].doDrop(_arg2)){
if (balls[_arg1][_local9].shouldCheckDestroyAfterDrop){
checkDestroyBalls.push(balls[_arg1][_local9]);
checkBothSides.push(false);
};
};
};
_local5 = (ballEnds[_arg1] + balls[_arg1][_local9].distance);
while (pathInfos[_arg1][_local7].distanceFromBeginning < _local5) {
_local7++;
if (_local7 >= pathInfos[_arg1].length){
_local7 = (pathInfos[_arg1].length - 1);
break;
};
};
setBallXY(balls[_arg1][_local9], pathInfos[_arg1], _local7, _local5, _arg2);
_local9++;
};
}
private function setBallMask(_arg1:Ball):void{
var _local3:int;
var _local4:Class;
var _local5:*;
var _local2:Boolean = pathInfos[_arg1.lineIndex][_arg1.pathInfoIndex].masked;
if (_local2 == !((_arg1.mask == null))){
return;
};
if (_local2){
_local3 = ((level - 1) % Config.LEVEL_NOOFLAYOUTS);
_local4 = Class(getDefinitionByName(((("com.novelgames.flashgames.mathlines.LevelBallMask" + _local3) + "_") + _arg1.lineIndex)));
_local5 = new (_local4);
_local5.visible = false;
ballMasksHolder.addChild(_local5);
_arg1.mask = _local5;
} else {
_local5 = _arg1.mask;
_arg1.mask = null;
ballMasksHolder.removeChild(_local5);
};
}
private function startNextLevel(_arg1:TimerEvent):void{
startLevel((level + 1));
}
private function checkGameOver():Boolean{
var _local1:int;
_local1 = 0;
while (_local1 < balls.length) {
if (balls[_local1].length == 0){
} else {
if ((ballEnds[_local1] + balls[_local1][(balls[_local1].length - 1)].distance) >= pathInfos[_local1][(pathInfos[_local1].length - 1)].distanceFromBeginning){
break;
};
};
_local1++;
};
if (_local1 >= balls.length){
return (false);
};
timer.stop();
unsetControl();
_local1 = 0;
while (_local1 < shootingBalls.length) {
ballsHolder.removeChild(shootingBalls[_local1]);
_local1++;
};
if (coin){
coinsHolder.removeChild(coin);
};
lastTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onLoseTime);
timer.start();
return (true);
}
private function getPreviousPoint(_arg1:Ball):Point{
var _local3:int;
var _local4:PathInfo;
var _local5:PathInfo;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local2:Number = ((ballEnds[_arg1.lineIndex] + _arg1.distance) - Config.BALL_SIZE);
_local9 = _arg1.pathInfoIndex;
while (_local9 > 0) {
_local4 = pathInfos[_arg1.lineIndex][_local9];
if ((((_local4.distanceFromBeginning >= _local2)) && (((_local4.distanceFromBeginning - _local4.distanceFromPrevious) <= _local2)))){
break;
};
_local9--;
};
if (_local9 == 0){
return (new Point(pathInfos[_arg1.lineIndex][0].x, pathInfos[_arg1.lineIndex][0].y));
};
_local5 = pathInfos[_arg1.lineIndex][(_local9 - 1)];
_local6 = ((_local2 - _local5.distanceFromBeginning) / _local4.distanceFromPrevious);
_local7 = ((_local5.x * (1 - _local6)) + (_local4.x * _local6));
_local8 = ((_local5.y * (1 - _local6)) + (_local4.y * _local6));
return (new Point(_local7, _local8));
}
public function set score(_arg1:int):void{
__score = _arg1;
scoreText.text = _arg1.toString();
}
private function onPlayTime(_arg1:TimerEvent):void{
var _local2:int = NewTimer.getTimer();
_arg1.updateAfterEvent();
checkShowCoin(_local2);
moveShootingBalls((_local2 - lastTime));
moveBallLines(_local2);
checkDestroy(_local2);
checkCoinEffect(_local2);
if (!checkWin()){
checkGameOver();
};
lastTime = _local2;
}
private function addScores(_arg1:Array):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:ScorePopup;
var _local14:int;
var _local15:int;
_local14 = 0;
while (_local14 < _arg1.length) {
_local2 = _arg1[_local14].lineIndex;
_local3 = _arg1[_local14].min;
_local4 = _arg1[_local14].max;
_local5 = _arg1[_local14].combo;
_local6 = ((((_local4 - _local3) + 1) * Config.SCORE_BALL) + (_local5 * Config.SCORE_COMBO));
score = (score + _local6);
_local7 = balls[_local2][Math.floor(((_local3 + _local4) / 2))].x;
_local8 = balls[_local2][Math.floor(((_local3 + _local4) / 2))].y;
_local9 = balls[_local2][Math.ceil(((_local3 + _local4) / 2))].x;
_local10 = balls[_local2][Math.ceil(((_local3 + _local4) / 2))].y;
_local11 = ((_local7 + _local9) / 2);
_local12 = ((_local8 + _local10) / 2);
_local13 = new ScorePopup();
_local13.initialize(_local11, _local12, _local6);
scoresHolder.addChild(_local13);
_local14++;
};
}
private function updateExistingNumbers():void{
var _local2:int;
var _local3:int;
var _local1:Array = new Array();
_local2 = 0;
while (_local2 < noOfCreatedBalls.length) {
if (noOfCreatedBalls[_local2] < noOfBallsPerLine){
break;
};
_local2++;
};
if (_local2 < noOfCreatedBalls.length){
_local2 = Config.BALL_MINNUMBER;
while (_local2 <= Config.BALL_MAXNUMBER) {
_local1[_local2] = true;
_local2++;
};
} else {
_local2 = 0;
while (_local2 < balls.length) {
_local3 = 0;
while (_local3 < balls[_local2].length) {
_local1[balls[_local2][_local3].number] = true;
_local3++;
};
_local2++;
};
};
existingNumbers = new Array();
_local2 = Config.BALL_MINNUMBER;
while (_local2 <= Config.BALL_MAXNUMBER) {
if (_local1[_local2]){
existingNumbers.push(_local2);
};
_local2++;
};
}
private function createCoinPositions(_arg1:MovieClip):void{
var _local2:int;
coinPositions = new Array();
_local2 = 0;
while (true) {
if (!_arg1[("coin" + _local2)]){
break;
};
coinPositions[_local2] = new Point(_arg1[("coin" + _local2)].x, _arg1[("coin" + _local2)].y);
_arg1[("coin" + _local2)].visible = false;
_local2++;
};
}
private function startLevel(_arg1:int):void{
this.level = _arg1;
levelNoOfBalls = (Config.LEVEL_INITIALNOOFBALLS + ((_arg1 - 1) * Config.LEVEL_NOOFBALLSINCREASE));
levelBallSpeed = (Config.LEVEL_INITIALBALLSPEED + ((_arg1 - 1) * Config.LEVEL_BALLSPEEDINCREASE));
levelScore = (Config.LEVEL_INITIALSCORE + ((_arg1 - 1) * Config.LEVEL_SCOREINCREASE));
createLayout();
checkDestroyBalls = new Array();
checkBothSides = new Array();
hasCorrectColours = false;
message.showLevel(_arg1);
timer = new NewTimer(Config.MESSAGE_LEVELTIME, 1);
timer.addEventListener(TimerEvent.TIMER, startInitialBalls);
timer.start();
}
private function createLayout():void{
var _local2:Class;
var _local1:int = ((level - 1) % Config.LEVEL_NOOFLAYOUTS);
if (layout){
levelLayoutHolder.removeChild(layout);
};
_local2 = Class(getDefinitionByName(("com.novelgames.flashgames.mathlines.LevelLayout" + _local1)));
layout = new (_local2);
createPathInfos(layout);
createCoinPositions(layout);
cannon = layout.cannon;
levelLayoutHolder.addChild(layout);
}
private function setBallXY(_arg1:Ball, _arg2:Array, _arg3:int, _arg4:Number, _arg5:int):void{
var _local6:MovieClip;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_arg1.pathInfoIndex = _arg3;
setBallMask(_arg1);
if (_arg3 == 0){
_local8 = _arg2[0].x;
_local9 = _arg2[0].y;
} else {
_local7 = ((_arg4 - _arg2[(_arg3 - 1)].distanceFromBeginning) / _arg2[_arg3].distanceFromPrevious);
_local8 = ((_arg2[(_arg3 - 1)].x * (1 - _local7)) + (_arg2[_arg3].x * _local7));
_local9 = ((_arg2[(_arg3 - 1)].y * (1 - _local7)) + (_arg2[_arg3].y * _local7));
};
if (!_arg1.isInserting){
_arg1.x = _local8;
_arg1.y = _local9;
} else {
if (_arg1.doInsert(_local8, _local9, _arg5)){
_arg1.combo = 0;
checkDestroyBalls.push(_arg1);
checkBothSides.push(true);
};
};
}
private function createExplode(_arg1:Number, _arg2:Number):void{
var _local3:Explode = new Explode();
_local3.initialize(_arg1, _arg2);
explodesHolder.addChild(_local3);
}
private function checkShowCoin(_arg1:int):void{
var _local2:int;
if (coin == null){
if (_arg1 < coinAppearTime){
return;
};
coin = new Coin();
_local2 = Math.floor((Math.random() * coinPositions.length));
coin.initialize(coinPositions[_local2].x, coinPositions[_local2].y);
coinsHolder.addChild(coin);
} else {
if (_arg1 < coinDisappearTime){
return;
};
destroyCoin();
};
}
private function insertBall(_arg1:Ball, _arg2:int, _arg3:int):void{
var _local5:int;
var _local4:int = NewTimer.getTimer();
balls[_arg2].splice(_arg3, 0, _arg1);
_arg1.lineIndex = _arg2;
if (_arg3 == 0){
_arg1.ballIndex = balls[_arg2][(_arg3 + 1)].ballIndex;
} else {
_arg1.ballIndex = (balls[_arg2][(_arg3 - 1)].ballIndex + 1);
};
_arg1.distance = (_arg1.ballIndex * Config.BALL_SIZE);
_arg1.isInserting = true;
_arg1.insertX = _arg1.x;
_arg1.insertY = _arg1.y;
_arg1.startTime = _local4;
_local5 = (_arg3 + 1);
while (_local5 < balls[_arg2].length) {
balls[_arg2][_local5].ballIndex++;
balls[_arg2][_local5].targetDistance = (balls[_arg2][_local5].ballIndex * Config.BALL_SIZE);
balls[_arg2][_local5].isAdjusting = true;
balls[_arg2][_local5].adjustDistance = balls[_arg2][_local5].distance;
balls[_arg2][_local5].startTime = _local4;
_local5++;
};
}
private function onInitialBallsTime(_arg1:TimerEvent):void{
var _local5:int;
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((Config.BALL_INITIALSPEED * (_local2 - lastTime)) / 1000);
var _local4:Boolean;
_arg1.updateAfterEvent();
if ((totalDistance + _local3) >= maxDistance){
_local4 = true;
_local3 = (maxDistance - totalDistance);
};
_local5 = 0;
while (_local5 < ballEnds.length) {
ballEnds[_local5] = (ballEnds[_local5] + _local3);
updateBalls(_local5, _local2);
_local5++;
};
totalDistance = (totalDistance + _local3);
lastTime = _local2;
if (_local4){
timer.stop();
startPlay();
};
}
private function moveShootingBalls(_arg1:int):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local2:Number = ((Config.BALL_SHOOTSPEED * _arg1) / 1000);
_local3 = Math.ceil((_local2 / (Config.BALL_SIZE / 2)));
_local4 = 0;
while (_local4 < shootingBalls.length) {
_local5 = 1;
while (_local5 <= _local3) {
shootingBalls[_local4].x = (shootingBalls[_local4].x + ((shootingBalls[_local4].directionX * _local2) / _local3));
shootingBalls[_local4].y = (shootingBalls[_local4].y + ((shootingBalls[_local4].directionY * _local2) / _local3));
if ((((((((shootingBalls[_local4].x < (Config.BALL_MINX - (Config.BALL_SIZE / 2)))) || ((shootingBalls[_local4].x > (Config.BALL_MAXX + (Config.BALL_SIZE / 2)))))) || ((shootingBalls[_local4].y < (Config.BALL_MINY - (Config.BALL_SIZE / 2)))))) || ((shootingBalls[_local4].y > (Config.BALL_MAXY + (Config.BALL_SIZE / 2)))))){
ballsHolder.removeChild(shootingBalls[_local4]);
shootingBalls.splice(_local4, 1);
_local4--;
break;
};
if (((checkHitBalls(shootingBalls[_local4])) || (checkHitCoin(shootingBalls[_local4])))){
shootingBalls.splice(_local4, 1);
_local4--;
break;
};
_local5++;
};
_local4++;
};
}
private function moveBallLines(_arg1:int):void{
var _local3:int;
var _local4:int;
var _local2:Number = (((levelBallSpeed / balls.length) * (_arg1 - lastTime)) / 1000);
_local3 = 0;
while (_local3 < ballEnds.length) {
ballEnds[_local3] = (ballEnds[_local3] + _local2);
updateBalls(_local3, _arg1);
_local3++;
};
}
private function onPlayMouseDown(_arg1:MouseEvent):void{
var _local2:Ball;
var _local3:Point;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local3 = new Point(0, 0);
_local3 = this.globalToLocal(cannon.frontBall.localToGlobal(_local3));
_local2 = new Ball();
_local2.showNumber(cannon.frontBall.number);
_local2.showColour(cannon.frontBall.colourIndex);
_local2.x = _local3.x;
_local2.y = _local3.y;
_local4 = (mouseX - cannon.x);
_local5 = (mouseY - cannon.y);
_local6 = Math.sqrt(((_local4 * _local4) + (_local5 * _local5)));
_local2.directionX = (_local4 / _local6);
_local2.directionY = (_local5 / _local6);
shootingBalls.push(_local2);
ballsHolder.addChild(_local2);
updateExistingNumbers();
cannon.generateNewBall(hasCorrectColours, existingNumbers);
soundShoot.play();
}
private function onPlayKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.SPACE){
cannon.switchBalls();
};
}
private function onLoseTime(_arg1:TimerEvent):void{
var _local4:Number;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local2:int = NewTimer.getTimer();
var _local3:Number = ((Config.BALL_LOSESPEED * (_local2 - lastTime)) / 1000);
_arg1.updateAfterEvent();
_local5 = true;
_local6 = 0;
while (_local6 < balls.length) {
_local4 = pathInfos[_local6][(pathInfos[_local6].length - 1)].distanceFromBeginning;
ballEnds[_local6] = (ballEnds[_local6] + _local3);
updateBalls(_local6, _local2);
_local7 = (balls[_local6].length - 1);
while (_local7 >= 0) {
if ((ballEnds[_local6] + balls[_local6][_local7].distance) < _local4){
break;
};
ballsHolder.removeChild(balls[_local6][_local7]);
balls[_local6].splice(_local7, 1);
_local7--;
};
if (_local7 >= 0){
_local5 = false;
};
_local6++;
};
lastTime = _local2;
if (_local5){
timer.stop();
message.showGameOver();
soundGameOver.play();
timer = new NewTimer(Config.MESSAGE_GAMEOVERTIME, 1);
timer.addEventListener(TimerEvent.TIMER, showGameOver);
timer.start();
};
}
public function get score():int{
return (__score);
}
private function setControl():void{
clickDetector.addEventListener(MouseEvent.MOUSE_MOVE, onPlayMouseMove);
clickDetector.addEventListener(MouseEvent.MOUSE_DOWN, onPlayMouseDown);
clickDetector.buttonMode = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onPlayKeyDown);
stage.focus = stage;
}
private function onPlayMouseMove(_arg1:MouseEvent):void{
var _local2:Number;
_arg1.updateAfterEvent();
_local2 = ((Math.atan2((mouseY - cannon.y), (mouseX - cannon.x)) * 180) / Math.PI);
cannon.updateRotation(_local2);
}
private function getNextPoint(_arg1:Ball):Point{
var _local3:int;
var _local4:PathInfo;
var _local5:PathInfo;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local2:Number = ((ballEnds[_arg1.lineIndex] + _arg1.distance) + Config.BALL_SIZE);
_local9 = _arg1.pathInfoIndex;
while (_local9 < (pathInfos[_arg1.lineIndex].length - 1)) {
_local4 = pathInfos[_arg1.lineIndex][_local9];
if ((((_local4.distanceFromBeginning >= _local2)) && (((_local4.distanceFromBeginning - _local4.distanceFromPrevious) <= _local2)))){
break;
};
_local9++;
};
if (_local9 == 0){
return (new Point(pathInfos[_arg1.lineIndex][0].x, pathInfos[_arg1.lineIndex][0].y));
};
_local5 = pathInfos[_arg1.lineIndex][(_local9 - 1)];
_local6 = ((_local2 - _local5.distanceFromBeginning) / _local4.distanceFromPrevious);
_local7 = ((_local5.x * (1 - _local6)) + (_local4.x * _local6));
_local8 = ((_local5.y * (1 - _local6)) + (_local4.y * _local6));
return (new Point(_local7, _local8));
}
private function destroyCoin():void{
var _local1:int = NewTimer.getTimer();
coin.uninitialize();
coinsHolder.removeChild(coin);
coin = null;
while (coinAppearTime <= _local1) {
coinAppearTime = (coinAppearTime + Config.COIN_APPEARINTERVAL);
coinDisappearTime = (coinDisappearTime + Config.COIN_APPEARINTERVAL);
};
}
private function onStarsTime(_arg1:TimerEvent):void{
var _local5:int;
var _local6:Boolean;
var _local7:Boolean;
var _local8:int;
var _local9:int;
var _local2:int = NewTimer.getTimer();
var _local3:int = (_local2 - startTime);
var _local4:int = (lastTime - startTime);
_arg1.updateAfterEvent();
_local7 = true;
_local8 = 0;
while (_local8 < stars.length) {
_local6 = false;
_local9 = 0;
while (_local9 < stars[_local8].length) {
_local5 = (_local3 - (_local9 * Config.STAR_APPEARINTERVAL));
if (_local5 < 0){
break;
};
if (_local4 < (_local9 * Config.STAR_APPEARINTERVAL)){
stars[_local8][_local9].visible = true;
score = (score + Config.SCORE_STAR);
soundStar.play();
};
if (_local5 < Config.STAR_APPEARTIME){
stars[_local8][_local9].alpha = (1 - (_local5 / Config.STAR_APPEARTIME));
} else {
stars[_local8][_local9].visible = false;
if (_local9 == (stars[_local8].length - 1)){
_local6 = true;
};
};
_local9++;
};
if (!_local6){
_local7 = false;
};
_local8++;
};
lastTime = _local2;
if (_local7){
timer.stop();
score = (score + levelScore);
message.showLevelClear(levelScore);
soundLevelClear.play();
timer = new NewTimer(Config.MESSAGE_LEVELCLEARTIME, 1);
timer.addEventListener(TimerEvent.TIMER, startNextLevel);
timer.start();
};
}
private function checkHitBalls(_arg1:Ball):Boolean{
var _local4:Number;
var _local5:Number;
var _local6:Point;
var _local7:Point;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:int;
var _local2:Number = _arg1.x;
var _local3:Number = _arg1.y;
_local10 = 0;
while (_local10 < balls.length) {
_local11 = 0;
while (_local11 < balls[_local10].length) {
if (balls[_local10][_local11].mask != null){
} else {
_local4 = (_local2 - balls[_local10][_local11].x);
_local5 = (_local3 - balls[_local10][_local11].y);
if (Math.abs(_local4) > Config.BALL_SIZE){
} else {
if (Math.abs(_local5) > Config.BALL_SIZE){
} else {
if (((_local4 * _local4) + (_local5 * _local5)) > (Config.BALL_SIZE * Config.BALL_SIZE)){
} else {
_local6 = getPreviousPoint(balls[_local10][_local11]);
_local7 = getNextPoint(balls[_local10][_local11]);
_local4 = (_local6.x - _local2);
_local5 = (_local6.y - _local3);
_local8 = ((_local4 * _local4) + (_local5 * _local5));
_local4 = (_local7.x - _local2);
_local5 = (_local7.y - _local3);
_local9 = ((_local4 * _local4) + (_local5 * _local5));
if (_local8 < _local9){
insertBall(_arg1, _local10, _local11);
} else {
insertBall(_arg1, _local10, (_local11 + 1));
};
soundShoot.play();
return (true);
};
};
};
};
_local11++;
};
_local10++;
};
return (false);
}
private function checkHitCoin(_arg1:Ball):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:int;
var _local5:int;
if (coin == null){
return (false);
};
_local2 = (_arg1.x - coin.x);
_local3 = (_arg1.y - coin.y);
if (Math.abs(_local2) > ((Config.BALL_SIZE + Config.COIN_SIZE) / 2)){
return (false);
};
if (Math.abs(_local3) > ((Config.BALL_SIZE + Config.COIN_SIZE) / 2)){
return (false);
};
if (((_local2 * _local2) + (_local3 * _local3)) > (((Config.BALL_SIZE + Config.COIN_SIZE) * (Config.BALL_SIZE + Config.COIN_SIZE)) / 4)){
return (false);
};
hasCorrectColours = true;
hasCorrectColoursEndTime = (NewTimer.getTimer() + Config.COIN_EFFECTTIME);
_local4 = 0;
while (_local4 < balls.length) {
_local5 = 0;
while (_local5 < balls[_local4].length) {
balls[_local4][_local5].showCorrectColour();
_local5++;
};
_local4++;
};
cannon.frontBall.showCorrectColour();
cannon.backBall.showCorrectColour();
_local4 = 0;
while (_local4 < shootingBalls.length) {
shootingBalls[_local4].showCorrectColour();
_local4++;
};
destroyCoin();
ballsHolder.removeChild(_arg1);
soundCoin.play();
return (true);
}
private function startPlay():void{
cannon.generateBalls(hasCorrectColours);
shootingBalls = new Array();
setControl();
lastTime = NewTimer.getTimer();
coin = null;
coinAppearTime = (lastTime + Config.COIN_APPEARINTERVAL);
coinDisappearTime = (coinAppearTime + Config.COIN_APPEARTIME);
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onPlayTime);
timer.start();
}
private function checkWin():Boolean{
var _local1:int;
_local1 = 0;
while (_local1 < balls.length) {
if (winDistances[_local1] > 0){
} else {
if (noOfCreatedBalls[_local1] < noOfBallsPerLine){
} else {
if (balls[_local1].length > 0){
} else {
winDistances[_local1] = ballEnds[_local1];
};
};
};
_local1++;
};
_local1 = 0;
while (_local1 < winDistances.length) {
if (winDistances[_local1] < 0){
return (false);
};
_local1++;
};
timer.stop();
unsetControl();
_local1 = 0;
while (_local1 < shootingBalls.length) {
ballsHolder.removeChild(shootingBalls[_local1]);
_local1++;
};
if (coin){
coinsHolder.removeChild(coin);
};
createStars();
return (true);
}
private function createPathInfos(_arg1:MovieClip):void{
var _local2:int;
var _local3:PathInfo;
var _local4:int;
var _local5:int;
_local4 = 0;
while (true) {
if (!_arg1[("ball" + _local4)]){
break;
};
_local4++;
};
_local2 = _local4;
pathInfos = new Array();
_local4 = 0;
while (_local4 < _local2) {
pathInfos[_local4] = new Array();
_local4++;
};
_local4 = 0;
while (_local4 < _arg1.totalFrames) {
_arg1.gotoAndStop((_local4 + 1));
_local5 = 0;
while (_local5 < _local2) {
_local3 = new PathInfo(_arg1[("ball" + _local5)].x, _arg1[("ball" + _local5)].y);
if (((!((_arg1[("ballMask" + _local5)] == null))) && (!((_arg1[("ballMask" + _local5)].alpha == 0))))){
_local3.masked = true;
};
pathInfos[_local5].push(_local3);
_local5++;
};
_local4++;
};
_arg1.gotoAndStop(1);
_local4 = 0;
while (_local4 < _local2) {
_local5 = 1;
while (_local5 < pathInfos[_local4].length) {
pathInfos[_local4][_local5].updateDistanceFromPrevious(pathInfos[_local4][(_local5 - 1)]);
_local5++;
};
if (_arg1[("ballMask" + _local4)] != null){
_arg1[("ballMask" + _local4)].visible = false;
};
_local4++;
};
noOfBallsPerLine = Math.ceil((levelNoOfBalls / _local2));
noOfCreatedBalls = new Array();
winDistances = new Array();
_local4 = 0;
while (_local4 < _local2) {
noOfCreatedBalls[_local4] = 0;
winDistances[_local4] = -1;
_local4++;
};
}
private function createStars():void{
var _local1:Star;
var _local2:Number;
var _local3:int;
var _local4:Number;
var _local5:int;
var _local6:int;
stars = new Array();
_local5 = 0;
while (_local5 < winDistances.length) {
stars[_local5] = new Array();
_local3 = 0;
_local2 = winDistances[_local5];
while (_local2 < pathInfos[_local5][(pathInfos[_local5].length - 1)].distanceFromBeginning) {
_local1 = new Star();
while (pathInfos[_local5][_local3].distanceFromBeginning < _local2) {
_local3++;
if (_local3 >= pathInfos[_local5].length){
_local3 = (pathInfos[_local5].length - 1);
break;
};
};
if (_local3 == 0){
_local1.x = pathInfos[_local5][0].x;
_local1.y = pathInfos[_local5][0].y;
} else {
_local4 = ((_local2 - pathInfos[_local5][(_local3 - 1)].distanceFromBeginning) / pathInfos[_local5][_local3].distanceFromPrevious);
_local1.x = ((pathInfos[_local5][(_local3 - 1)].x * (1 - _local4)) + (pathInfos[_local5][_local3].x * _local4));
_local1.y = ((pathInfos[_local5][(_local3 - 1)].y * (1 - _local4)) + (pathInfos[_local5][_local3].y * _local4));
};
stars[_local5].push(_local1);
starsHolder.addChild(_local1);
_local2 = (_local2 + Config.STAR_SPACING);
};
_local6 = 0;
while (_local6 < stars[_local5].length) {
stars[_local5][_local6].visible = false;
_local6++;
};
_local5++;
};
startTime = NewTimer.getTimer();
lastTime = startTime;
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onStarsTime);
timer.start();
}
private function checkCoinEffect(_arg1:int):void{
var _local2:int;
var _local3:int;
if (!hasCorrectColours){
return;
};
if (_arg1 < hasCorrectColoursEndTime){
return;
};
hasCorrectColours = false;
_local2 = 0;
while (_local2 < balls.length) {
_local3 = 0;
while (_local3 < balls[_local2].length) {
balls[_local2][_local3].showRandomColour();
_local3++;
};
_local2++;
};
cannon.frontBall.showRandomColour();
cannon.backBall.showRandomColour();
_local2 = 0;
while (_local2 < shootingBalls.length) {
shootingBalls[_local2].showRandomColour();
_local2++;
};
}
private function checkDestroy(_arg1:int):void{
var _local3:Object;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:Boolean;
var _local10:int;
var _local11:int;
var _local12:int;
var _local13:int;
var _local2:Array = new Array();
if (checkDestroyBalls.length == 0){
return;
};
_local11 = 0;
while (_local11 < checkDestroyBalls.length) {
_local4 = checkDestroyBalls[_local11].lineIndex;
_local5 = (checkDestroyBalls[_local11].ballIndex - balls[_local4][0].ballIndex);
_local10 = checkDestroyBalls[_local11].combo;
_local6 = _local5;
_local7 = _local5;
_local13 = (_local5 - 1);
while (_local13 >= 0) {
if ((balls[_local4][_local13].number + checkDestroyBalls[_local11].number) != (Config.BALL_MINNUMBER + Config.BALL_MAXNUMBER)){
break;
};
balls[_local4][_local13].shouldDestroy = true;
balls[_local4][_local13].combo = _local10;
_local6 = _local13;
_local13--;
};
if (checkBothSides[_local11]){
_local13 = (_local5 + 1);
while (_local13 < balls[_local4].length) {
if ((balls[_local4][_local13].number + checkDestroyBalls[_local11].number) != (Config.BALL_MINNUMBER + Config.BALL_MAXNUMBER)){
break;
};
balls[_local4][_local13].shouldDestroy = true;
balls[_local4][_local13].combo = _local10;
_local7 = _local13;
_local13++;
};
};
if (((!((_local6 == _local5))) || (!((_local7 == _local5))))){
checkDestroyBalls[_local11].shouldDestroy = true;
_local3 = new Object();
_local3.lineIndex = _local4;
_local3.min = _local6;
_local3.max = _local7;
_local3.combo = _local10;
_local2.push(_local3);
};
_local11++;
};
checkDestroyBalls = new Array();
checkBothSides = new Array();
if (_local2.length == 0){
return;
};
addScores(_local2);
_local11 = 0;
while (_local11 < balls.length) {
_local8 = 0;
_local12 = 0;
while (_local12 < balls[_local11].length) {
if (balls[_local11][_local12].shouldDestroy){
_local8++;
_local9 = true;
_local10 = balls[_local11][_local12].combo;
createExplode(balls[_local11][_local12].x, balls[_local11][_local12].y);
ballsHolder.removeChild(balls[_local11][_local12]);
balls[_local11].splice(_local12, 1);
_local12--;
} else {
if (_local8 > 0){
balls[_local11][_local12].ballIndex = (balls[_local11][_local12].ballIndex - _local8);
balls[_local11][_local12].targetDistance = (balls[_local11][_local12].ballIndex * Config.BALL_SIZE);
balls[_local11][_local12].isDropping = true;
balls[_local11][_local12].dropDistance = balls[_local11][_local12].distance;
balls[_local11][_local12].startTime = _arg1;
if (_local9){
balls[_local11][_local12].shouldCheckDestroyAfterDrop = true;
balls[_local11][_local12].combo = (_local10 + 1);
} else {
balls[_local11][_local12].shouldCheckDestroyAfterDrop = false;
};
_local9 = false;
};
};
_local12++;
};
_local11++;
};
soundDestroy.play();
}
private function startInitialBalls(_arg1:TimerEvent):void{
var _local3:int;
var _local2:Number = Number.POSITIVE_INFINITY;
message.hide();
balls = new Array();
ballEnds = new Array();
_local3 = 0;
while (_local3 < pathInfos.length) {
balls[_local3] = new Array();
ballEnds[_local3] = (-(Config.BALL_SIZE) * noOfBallsPerLine);
if (pathInfos[_local3][(pathInfos[_local3].length - 1)].distanceFromBeginning < _local2){
_local2 = pathInfos[_local3][(pathInfos[_local3].length - 1)].distanceFromBeginning;
};
_local3++;
};
totalDistance = 0;
maxDistance = ((_local2 * Config.BALL_INITIALPERCENT) / 100);
lastTime = NewTimer.getTimer();
timer = new NewTimer(1, 0);
timer.addEventListener(TimerEvent.TIMER, onInitialBallsTime);
timer.start();
}
private function unsetControl():void{
clickDetector.removeEventListener(MouseEvent.MOUSE_MOVE, onPlayMouseMove);
clickDetector.removeEventListener(MouseEvent.MOUSE_DOWN, onPlayMouseDown);
clickDetector.buttonMode = false;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onPlayKeyDown);
}
}
}//package com.novelgames.flashgames.mathlines
Section 15
//LevelBallMask1_0 (com.novelgames.flashgames.mathlines.LevelBallMask1_0)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class LevelBallMask1_0 extends MovieClip {
}
}//package com.novelgames.flashgames.mathlines
Section 16
//LevelBallMask2_0 (com.novelgames.flashgames.mathlines.LevelBallMask2_0)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class LevelBallMask2_0 extends MovieClip {
}
}//package com.novelgames.flashgames.mathlines
Section 17
//LevelBallMask2_1 (com.novelgames.flashgames.mathlines.LevelBallMask2_1)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class LevelBallMask2_1 extends MovieClip {
}
}//package com.novelgames.flashgames.mathlines
Section 18
//LevelLayout0 (com.novelgames.flashgames.mathlines.LevelLayout0)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class LevelLayout0 extends MovieClip {
public var coin1:Coin;
public var coin2:Coin;
public var ball0:Ball;
public var coin3:Coin;
public var cannon:Cannon;
public var coin0:Coin;
}
}//package com.novelgames.flashgames.mathlines
Section 19
//LevelLayout1 (com.novelgames.flashgames.mathlines.LevelLayout1)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class LevelLayout1 extends MovieClip {
public var coin1:Coin;
public var coin2:Coin;
public var ballMask0:LevelBallMask1_0;
public var ball0:Ball;
public var cannon:Cannon;
public var coin0:Coin;
}
}//package com.novelgames.flashgames.mathlines
Section 20
//LevelLayout2 (com.novelgames.flashgames.mathlines.LevelLayout2)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class LevelLayout2 extends MovieClip {
public var coin1:Coin;
public var ballMask0:LevelBallMask2_0;
public var ballMask1:LevelBallMask2_1;
public var ball0:Ball;
public var ball1:Ball;
public var cannon:Cannon;
public var coin0:Coin;
}
}//package com.novelgames.flashgames.mathlines
Section 21
//Main (com.novelgames.flashgames.mathlines.Main)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import com.novelgames.flashgames.common.*;
import flash.media.*;
import mochi.as3.*;
public class Main extends MainDevelopment {
public var title:Title;
public function Main(){
stage.showDefaultContextMenu = false;
showMochi();
}
override protected function getMusicGame():Sound{
return (new MusicGame());
}
override protected function getTitle():Title{
return (title);
}
private function showMochi():void{
var _local1:MovieClip = new MovieClip();
addChild(_local1);
MochiAd.showPreGameAd({clip:_local1, id:"fe5a90b4545aa6e1", res:"600x400"});
}
override protected function getGame():Game{
return (new Game());
}
}
}//package com.novelgames.flashgames.mathlines
Section 22
//Message (com.novelgames.flashgames.mathlines.Message)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.events.*;
public class Message extends MovieClip {
private var messagePlayAgain:MessagePlayAgain;
private var messageLevelClear:MessageLevelClear;
private var messageLevel:MessageLevel;
public function Message(){
stop();
}
public function showGameOver():void{
hide();
gotoAndStop("gameOver");
}
public function showLevelClear(_arg1:int):void{
hide();
messageLevelClear = new MessageLevelClear();
messageLevelClear.scoreText.text = (Config.SCOREPOPUP_PREFIX + _arg1);
this.addChild(messageLevelClear);
}
public function showLevel(_arg1:int):void{
hide();
messageLevel = new MessageLevel();
messageLevel.levelText.text = _arg1.toString();
this.addChild(messageLevel);
}
public function hide():void{
if (messageLevel){
this.removeChild(messageLevel);
messageLevel = null;
};
if (messageLevelClear){
this.removeChild(messageLevelClear);
messageLevelClear = null;
};
gotoAndStop("hide");
}
private function moreButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoMoreGamesURL3();
}
public function showPlayAgain():void{
messagePlayAgain = new MessagePlayAgain();
messagePlayAgain.playAgainButton.addEventListener(MouseEvent.CLICK, playAgainButtonClicked);
messagePlayAgain.homeButton.addEventListener(MouseEvent.CLICK, homeButtonClicked);
messagePlayAgain.logoButton.addEventListener(MouseEvent.CLICK, logoButtonClicked);
messagePlayAgain.moreGames.addEventListener(MouseEvent.CLICK, moreButtonClicked);
addChild(messagePlayAgain);
}
private function logoButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoMoreGamesURL2();
}
private function homeButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).sendeScore();
}
private function playAgainButtonClicked(_arg1:MouseEvent):void{
Object(parent.parent).gotoGamePage();
}
}
}//package com.novelgames.flashgames.mathlines
Section 23
//MessageLevel (com.novelgames.flashgames.mathlines.MessageLevel)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.text.*;
public dynamic class MessageLevel extends MovieClip {
public var levelText:TextField;
}
}//package com.novelgames.flashgames.mathlines
Section 24
//MessageLevelClear (com.novelgames.flashgames.mathlines.MessageLevelClear)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
import flash.text.*;
public dynamic class MessageLevelClear extends MovieClip {
public var scoreText:TextField;
}
}//package com.novelgames.flashgames.mathlines
Section 25
//MessagePlayAgain (com.novelgames.flashgames.mathlines.MessagePlayAgain)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class MessagePlayAgain extends MovieClip {
public var homeButton:SimpleButton;
public var moreGames:SimpleButton;
public var logoButton:SimpleButton;
public var playAgainButton:SimpleButton;
}
}//package com.novelgames.flashgames.mathlines
Section 26
//MusicGame (com.novelgames.flashgames.mathlines.MusicGame)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class MusicGame extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 27
//PathInfo (com.novelgames.flashgames.mathlines.PathInfo)
package com.novelgames.flashgames.mathlines {
public class PathInfo {
public var masked:Boolean;
public var distanceFromPrevious:Number;
public var x:Number;
public var y:Number;
public var distanceFromBeginning:Number;
public function PathInfo(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
distanceFromPrevious = 0;
distanceFromBeginning = 0;
masked = false;
}
public function updateDistanceFromPrevious(_arg1:PathInfo):void{
var _local2:Number = (x - _arg1.x);
var _local3:Number = (y - _arg1.y);
distanceFromPrevious = Math.sqrt(((_local2 * _local2) + (_local3 * _local3)));
distanceFromBeginning = (distanceFromPrevious + _arg1.distanceFromBeginning);
}
}
}//package com.novelgames.flashgames.mathlines
Section 28
//ScorePopup (com.novelgames.flashgames.mathlines.ScorePopup)
package com.novelgames.flashgames.mathlines {
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;
scoreText.text = (Config.SCOREPOPUP_PREFIX + _arg3);
originalY = _arg2;
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.mathlines
Section 29
//SoundCoin (com.novelgames.flashgames.mathlines.SoundCoin)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class SoundCoin extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 30
//SoundDestroy (com.novelgames.flashgames.mathlines.SoundDestroy)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class SoundDestroy extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 31
//SoundGameOver (com.novelgames.flashgames.mathlines.SoundGameOver)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class SoundGameOver extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 32
//SoundLevelClear (com.novelgames.flashgames.mathlines.SoundLevelClear)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class SoundLevelClear extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 33
//SoundShoot (com.novelgames.flashgames.mathlines.SoundShoot)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class SoundShoot extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 34
//SoundStar (com.novelgames.flashgames.mathlines.SoundStar)
package com.novelgames.flashgames.mathlines {
import flash.media.*;
public dynamic class SoundStar extends Sound {
}
}//package com.novelgames.flashgames.mathlines
Section 35
//Star (com.novelgames.flashgames.mathlines.Star)
package com.novelgames.flashgames.mathlines {
import flash.display.*;
public dynamic class Star extends MovieClip {
}
}//package com.novelgames.flashgames.mathlines
Section 36
//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