home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2008-09-02 | 56.5 KB | 1,770 lines
package { import com.kongregate.as3.client.*; import com.kongregate.as3.client.events.*; import com.mochi.*; import com.simianlogic.*; import flash.display.DisplayObject; import flash.display.MovieClip; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.net.*; import flash.text.*; import flash.utils.Timer; import flash.utils.getTimer; import flash.utils.setTimeout; import org.cove.ape.*; public dynamic class filler extends Sprite { public static const MAXAREA:int = 230100; public static const COLORLIST:Array = [3394815,3407718,16763955,13382655,4060416,47349,3997941,10092400,15861]; public static var GAME_OPTIONS:Object = { "id":"74eaa3b8c08bf451", "res":"600x500" }; public var verticalMenu:Sprite; public var percentFilled:Number; private var splashSprite:DisplayObject; public var timerText:TextField; private var modAlert24Mp3:Class; public var activeBall:growthSprite; private var playerScore:int = 0; private var rollOverMp3:Class; public var soundOverlay:Sprite; public var pauseText:TextField; public var bg:Sprite; private var logoSprite:DisplayObject; public var timeLeft:Number; public var ballsLeft:Number; public var soundOptions:Array; private var musicMp3:Class; private var rollOverSound:Sound; private var Send40K:Boolean = true; public var fillerBalls:Group; private var TotalBallsMade:int = 0; private var thudSound:Sound; public var levelText:TextField; public var livesText:TextField; public var LASTUPDATE:int; public var player:Group; public var scoreText:TextField; public var kongText:TextField; private var kongSplash:Class; public var redCount:int = 0; private var alert24Sound:Sound; private var flingSound:Sound; private var playerName:String = "<your name>"; private var musicChannel:SoundChannel; private var boopMp3:Class; private var alert05Sound:Sound; public var bouncyBalls:Group; public var LASTAD:int = 0; public var kongSprite:Sprite; public var SOUNDENABLED:Boolean = true; private var bounceSound:Sound; private var kongLogo:Class; private var modAlert05Mp3:Class; public var pauseOverlay:Sprite; public var MUSICENABLED:Boolean = true; public var world:Group; public var GAMEPAUSED:Boolean = false; private var body:MovieClip = null; public var CURRENTLEVEL:int = 1; public var livesLeft:Number; public var pctText:TextField; public var ballText:TextField; private var kongregate:KongregateAPI; public var slideCount:int; private var HighestPercentFilled:Number = 0; private var thudMp3:Class; private var musicSound:Sound; private var flingMp3:Class; public function filler() { kongLogo = filler_kongLogo; kongSplash = filler_kongSplash; musicMp3 = filler_musicMp3; flingMp3 = filler_flingMp3; rollOverMp3 = filler_rollOverMp3; modAlert05Mp3 = filler_modAlert05Mp3; modAlert24Mp3 = filler_modAlert24Mp3; boopMp3 = filler_boopMp3; thudMp3 = filler_thudMp3; TotalBallsMade = 0; HighestPercentFilled = 0; Send40K = true; body = null; CURRENTLEVEL = 1; GAMEPAUSED = false; SOUNDENABLED = true; MUSICENABLED = true; LASTAD = 0; playerName = "<your name>"; playerScore = 0; redCount = 0; soundOptions = [1,1,1,1]; super(); if(stage != null) { init(false); } } private function showMenu(param1:Event = null) : void { verticalMenu.visible = true; } private function freezeActiveBall() : void { var _loc1_:Array = null; var _loc2_:growthSprite = null; _loc1_ = player.getAll(); if(_loc1_.length > 0 && _loc1_[0] == activeBall) { player.removeParticle(activeBall); } _loc2_ = new growthSprite(activeBall.position.x,activeBall.position.y,activeBall.radius,13421772); fillerBalls.addParticle(_loc2_); if(SOUNDENABLED) { } playerScore += Math.round(3.1415 * activeBall.radius * activeBall.radius / 100); if(playerScore > 40000 && Send40K) { Send40K = false; kongregate.stats.submit("40K Points",1); } scoreText.text = "Score: " + playerScore; tallyPercent(); if(percentFilled >= 66.555) { return; } ++TotalBallsMade; --ballsLeft; if(ballsLeft < 0) { ouch(); } ballsLeft = Math.max(ballsLeft,0); ballText.text = "Balls: " + ballsLeft; } private function mouseUp(param1:Event) : void { var _loc2_:Array = null; _loc2_ = player.getAll(); if(_loc2_.length > 0 && _loc2_[0] == activeBall) { freezeActiveBall(); } } public function shrinkKongSprite() : void { kongSprite.graphics.clear(); kongSprite.graphics.beginFill(0); kongSprite.graphics.lineStyle(1,16777215,1); kongSprite.graphics.drawRect(0,15,151,40); kongSprite.graphics.endFill(); kongText.visible = false; } public function fadeBody() : void { var _loc1_:Timer = null; if(!body || !contains(body)) { return; } _loc1_ = new Timer(10,40); _loc1_.addEventListener("timer",fadeHandler); _loc1_.addEventListener("timerComplete",fadeHandlerDone); slideCount = 0; body.alpha = 0; _loc1_.start(); } private function redTimerHandlerDone(param1:TimerEvent) : void { bg.graphics.clear(); bg.graphics.beginFill(5592405); bg.graphics.drawRect(0,0,600,500); bg.graphics.endFill(); } private function startLevel(param1:int) : void { var _loc2_:int = 0; var _loc3_:Array = null; var _loc4_:Array = null; var _loc5_:int = 0; var _loc6_:constantVSprite = null; if(Boolean(body) && contains(body)) { removeChild(body); } if(GAMEPAUSED) { pause(); } livesLeft = param1 + 1; timeLeft = (60 + param1 * 30) * 1000; ballsLeft = 18 + 2 * param1; _loc2_ = 4.5; _loc3_ = [new Vector(-_loc2_,-_loc2_),new Vector(_loc2_,-_loc2_),new Vector(_loc2_,_loc2_),new Vector(-_loc2_,_loc2_)]; _loc4_ = bouncyBalls.getAll(); _loc5_ = 0; while(_loc5_ < _loc4_.length) { bouncyBalls.removeParticle(_loc4_[_loc5_]); _loc5_++; } _loc4_ = fillerBalls.getAll(); _loc5_ = 0; while(_loc5_ < _loc4_.length) { fillerBalls.removeParticle(_loc4_[_loc5_]); _loc5_++; } _loc5_ = 0; while(_loc5_ < param1 + 1) { (_loc6_ = new constantVSprite(Math.random() * 500 + 50,Math.random() * 350 + 125)).setVelocity(_loc3_[int(Math.random() * 3.9999)]); bouncyBalls.addParticle(_loc6_); _loc5_++; } pctText.text = "0% cleared"; levelText.text = "Level: " + param1; livesText.text = "Lives: " + livesLeft; timerText.text = "Time left: " + Math.round(timeLeft / 100); timerText.x = 600 - (timerText.textWidth + 5); ballText.text = "Balls: " + ballsLeft; LASTUPDATE = getTimer(); } public function nextLevel(param1:Event = null) : void { if(CURRENTLEVEL == 5) { kongregate.stats.submit("Games Past Level 5",1); } if(CURRENTLEVEL == 10) { kongregate.stats.submit("Games Past Level 10",1); } if(CURRENTLEVEL == 15) { kongregate.stats.submit("Games Past Level 15",1); } if(CURRENTLEVEL == 20) { kongregate.stats.submit("Games Past Level 20",1); } if(CURRENTLEVEL == 25) { kongregate.stats.submit("Games Past Level 25",1); } ++CURRENTLEVEL; startLevel(CURRENTLEVEL); } public function dismissOverlay(param1:Event = null) : void { if(body) { if(contains(body)) { removeChild(body); } body = null; } if(livesLeft == 0) { newGameButton(); return; } if(percentFilled > 65.55) { nextLevel(); } if(GAMEPAUSED) { pause(); } } public function getOptions() : Object { var _loc1_:Object = null; var _loc2_:String = null; _loc1_ = { "clip":body, "id":"74eaa3b8c08bf451" }; for(_loc2_ in GAME_OPTIONS) { _loc1_[_loc2_] = GAME_OPTIONS[_loc2_]; } return _loc1_; } public function flashRed() : void { var _loc1_:Timer = null; bg.graphics.clear(); bg.graphics.beginFill(5592405); bg.graphics.drawRect(0,0,600,500); bg.graphics.endFill(); bg.graphics.beginFill(5570560); bg.graphics.drawRect(0,100,600,400); bg.graphics.endFill(); _loc1_ = new Timer(5,20); _loc1_.addEventListener("timer",redTimerHandler); _loc1_.addEventListener("timerComplete",redTimerHandlerDone); redCount = 0; _loc1_.start(); } public function getAverageSize() : int { var _loc1_:Array = null; var _loc2_:Number = NaN; var _loc3_:int = 0; _loc1_ = fillerBalls.getAll(); _loc2_ = 0; _loc3_ = 0; while(_loc3_ < _loc1_.length) { _loc2_ += _loc1_[_loc3_].radius; _loc3_++; } return Math.round(_loc2_ / _loc1_.length); } private function toggleSFX(param1:Event = null) : void { if(SOUNDENABLED) { SOUNDENABLED = false; param1.target.label = "SFX On"; } else { SOUNDENABLED = true; param1.target.label = "SFX Off"; } } private function run(param1:Event) : void { var _loc2_:Array = null; var _loc3_:int = 0; var _loc4_:Array = null; var _loc5_:constantVSprite = null; var _loc6_:constantVSprite = null; var _loc7_:Array = null; var _loc8_:int = 0; var _loc9_:SoundTransform = null; if(GAMEPAUSED) { return; } _loc2_ = bouncyBalls.getAll(); _loc3_ = 0; while(_loc3_ < _loc2_.length) { if(_loc2_[_loc3_].position.x < 0 || _loc2_[_loc3_].position.x > 600 || _loc2_[_loc3_].position.y > 500 || _loc2_[_loc3_].position.y < 100) { if(mouseX < 300) { (_loc5_ = new constantVSprite(570,130)).setVelocity(new Vector(-4.5,4.5)); bouncyBalls.addParticle(_loc5_); bouncyBalls.removeParticle(_loc2_[_loc3_]); } else { (_loc6_ = new constantVSprite(30,130)).setVelocity(new Vector(4.5,4.5)); bouncyBalls.addParticle(_loc6_); bouncyBalls.removeParticle(_loc2_[_loc3_]); } } _loc3_++; } APEngine.step(); APEngine.paint(); timeLeft -= getTimer() - LASTUPDATE; timeLeft = Math.max(0,timeLeft); LASTUPDATE = getTimer(); timerText.text = "Time left: " + Math.round(timeLeft / 100); if((_loc4_ = player.getAll()).length > 0) { _loc7_ = bouncyBalls.getAll(); _loc8_ = 0; while(_loc8_ < _loc7_.length) { if(_loc7_[_loc8_].position.distance(activeBall.position) < activeBall.radius + _loc7_[_loc8_].radius + 0.25) { player.removeParticle(activeBall); if(SOUNDENABLED) { _loc9_ = new SoundTransform(1.5); thudSound.play(0,0,_loc9_); } ouch(); return; } _loc8_++; } if(activeBall.radius > 187.5) { freezeActiveBall(); return; } _loc7_ = fillerBalls.getAll(); _loc8_ = 0; while(_loc8_ < _loc7_.length) { if(_loc7_[_loc8_].position.distance(activeBall.position) < activeBall.radius + _loc7_[_loc8_].radius + 0.25) { freezeActiveBall(); return; } _loc8_++; } } } public function fetchHighScores(param1:Object = null) : void { var _loc2_:Sprite = null; var _loc3_:TextScoreTable = null; var _loc4_:TextField = null; var _loc5_:Object = null; if(percentFilled >= 66.6) { return; } if(!GAMEPAUSED) { pause(); } if(body) { if(contains(body)) { removeChild(body); } body = null; } body = new MovieClip(); body.x = 0; body.y = 0; addChild(body); fadeBody(); _loc2_ = new Sprite(); _loc2_.graphics.beginFill(0); _loc2_.graphics.drawRect(100,150,400,300); _loc2_.graphics.endFill(); _loc2_.graphics.beginFill(3355443); _loc2_.graphics.drawRect(102,152,396,296); _loc2_.graphics.endFill(); body.addChild(_loc2_); _loc3_ = new TextScoreTable(); trace("table created..."); body.addChild(_loc3_); _loc3_.x = 105; _loc3_.y = 155; _loc3_.init(); (_loc4_ = new_tf("center")).x = 235; _loc4_.y = 420; _loc4_.width = 150; _loc4_.htmlText = "<font size=\'size:8px\'>(Click to Continue)</font>"; body.addChild(_loc4_); body.addEventListener("click",dismissOverlay); _loc5_ = getOptions(); _loc3_.reset("Fetching high scores..."); MochiAd.fetchHighScores(_loc5_,_loc3_,"gotScores"); } private function closeScoresNew(param1:Event) : void { newGameButton(); } private function ouch() : void { var _loc1_:SoundTransform = null; flashRed(); --livesLeft; livesText.text = "Lives: " + livesLeft; if(livesLeft <= 0) { GAMEPAUSED = true; stopMusic(); _loc1_ = new SoundTransform(0.5); if(SOUNDENABLED) { alert05Sound.play(0,0,_loc1_); } setTimeout(sendHighScore,400); } } public function outOfBounds(param1:Event = null) : void { var _loc2_:SoundTransform = null; player.removeParticle(activeBall); if(SOUNDENABLED) { _loc2_ = new SoundTransform(1.5); thudSound.play(0,0,_loc2_); } ouch(); } public function softBounceSound(param1:Event) : void { var _loc2_:SoundTransform = null; if(!SOUNDENABLED) { return; } _loc2_ = new SoundTransform(0.15); bounceSound.play(0,0,_loc2_); } public function startMusic() : void { var _loc1_:SoundTransform = null; if(musicChannel) { musicChannel.stop(); } if(!MUSICENABLED) { return; } _loc1_ = new SoundTransform(0.25); musicChannel = musicSound.play(0,100,_loc1_); } public function showInterLevel(param1:Object = null) : void { var opts:Object = null; var ev:Object = param1; LASTAD = getTimer(); if(GAMEPAUSED) { pause(); } GAMEPAUSED = true; if(body) { if(contains(body)) { removeChild(body); } body = null; } body = new MovieClip(); body.x = 0; body.y = 0; addChild(body); fadeBody(); opts = getOptions(); opts.ad_started = function():void { }; opts.ad_finished = newGame; MochiAd.showInterLevelAd(opts); } private function drawUI() : void { var _loc1_:TextFormat = null; var _loc2_:TextField = null; var _loc3_:TextField = null; var _loc4_:ezButton = null; var _loc5_:ezButton = null; var _loc6_:ezButton = null; var _loc7_:ezButton = null; var _loc8_:ezButton = null; var _loc9_:ezButton = null; _loc1_ = new TextFormat(); _loc1_.font = "Arial"; _loc1_.color = 16777215; _loc1_.size = 18; pauseText = new TextField(); pauseText.selectable = false; pauseText.defaultTextFormat = _loc1_; pauseText.text = "Game Paused"; pauseText.width = 250; pauseText.x = 245; pauseText.y = 300; pauseOverlay = new Sprite(); pauseOverlay.graphics.beginFill(0,0.5); pauseOverlay.graphics.drawRect(0,100,600,400); pauseOverlay.graphics.endFill(); _loc1_.size = 24; _loc2_ = new TextField(); _loc2_.selectable = false; _loc2_.defaultTextFormat = _loc1_; _loc2_.text = "filler: a game"; _loc2_.width = 400; _loc2_.x = 5; _loc2_.y = 5; bg.addChild(_loc2_); _loc1_.size = 16; _loc3_ = new TextField(); _loc3_.selectable = false; _loc3_.defaultTextFormat = _loc1_; _loc3_.htmlText = "<a href=\'http://www.simianlogic3d.com/blog\'>by SimianLogic</a>"; _loc3_.width = 400; _loc3_.x = 50; _loc3_.y = 35; bg.addChild(_loc3_); pctText = new TextField(); pctText.defaultTextFormat = _loc1_; pctText.text = "0% cleared"; pctText.selectable = false; pctText.width = 400; pctText.x = 260; pctText.y = 75; bg.addChild(pctText); scoreText = new TextField(); scoreText.defaultTextFormat = _loc1_; scoreText.text = "Score: 0"; scoreText.selectable = false; scoreText.width = 400; scoreText.x = 300 - scoreText.textWidth / 2; scoreText.y = 35; bg.addChild(scoreText); levelText = new TextField(); levelText.defaultTextFormat = _loc1_; levelText.text = "Level 1"; levelText.selectable = false; levelText.width = 200; levelText.x = 5; levelText.y = 75; bg.addChild(levelText); livesText = new TextField(); livesText.defaultTextFormat = _loc1_; livesText.text = "Lives: 22"; livesText.selectable = false; livesText.width = 400; livesText.x = 530; livesText.y = 75; bg.addChild(livesText); ballText = new TextField(); ballText.defaultTextFormat = _loc1_; ballText.text = "Balls: 20"; ballText.selectable = false; ballText.width = 400; ballText.x = 530; ballText.y = 55; bg.addChild(ballText); timerText = new TextField(); timerText.defaultTextFormat = _loc1_; timerText.text = "Time left: 900"; timerText.selectable = false; timerText.width = 400; timerText.x = 500 - (timerText.textWidth + 5); timerText.y = 5; bg.addChild(timerText); (_loc4_ = new ezButton("Pause","pause",100,30)).x = 300; _loc4_.y = 5; bg.addChild(_loc4_); _loc4_.addEventListener("button_pause",pause); (_loc5_ = new ezButton("Menu","showMenu",100,30)).addEventListener(MouseEvent.ROLL_OVER,showMenu); _loc5_.x = 200; _loc5_.y = 5; bg.addChild(_loc5_); verticalMenu = new Sprite(); verticalMenu.addEventListener(MouseEvent.ROLL_OUT,hideMenu); verticalMenu.x = _loc5_.x - 1; verticalMenu.y = 0; verticalMenu.visible = false; verticalMenu.graphics.beginFill(0); verticalMenu.graphics.drawRect(0,0,102,100); verticalMenu.graphics.endFill(); (_loc6_ = new ezButton("NewGame","newGame",100,25)).x = 1; _loc6_.y = 2; verticalMenu.addChild(_loc6_); _loc6_.addEventListener("button_newGame",newGameButton); (_loc7_ = new ezButton("Instructions","help",100,25)).x = 1; _loc7_.y = 26; verticalMenu.addChild(_loc7_); _loc7_.addEventListener("button_help",showInstructions); (_loc8_ = new ezButton("SFX Off","sfx",100,25)).x = 1; _loc8_.y = 50; verticalMenu.addChild(_loc8_); _loc8_.addEventListener("button_sfx",toggleSFX); (_loc9_ = new ezButton("Music Off","music",100,25)).x = 1; _loc9_.y = 74; verticalMenu.addChild(_loc9_); _loc9_.addEventListener("button_music",toggleMusic); bg.addChild(verticalMenu); } private function mouseDown(param1:Event) : void { var _loc2_:Array = null; if(GAMEPAUSED) { return; } _loc2_ = player.getAll(); if(_loc2_.length > 0 && _loc2_[0] == activeBall) { player.removeParticle(activeBall); } if(mouseY > 105) { activeBall = new growthSprite(mouseX,mouseY,10,16777215,true); activeBall.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp); activeBall.sprite.addEventListener("outOfBoundsEvent",outOfBounds); player.addParticle(activeBall); } } public function buttonSound(param1:Event) : void { var _loc2_:SoundTransform = null; if(!SOUNDENABLED) { return; } _loc2_ = new SoundTransform(0.1); rollOverSound.play(0,0,_loc2_); } public function showInstruction2(param1:Event) : void { var _loc2_:Sprite = null; var _loc3_:TextField = null; var _loc4_:TextField = null; var _loc5_:String = null; var _loc6_:constantVSprite = null; var _loc7_:Sprite = null; var _loc8_:growthSprite = null; var _loc9_:Sprite = null; var _loc10_:growthSprite = null; var _loc11_:Sprite = null; var _loc12_:growthSprite = null; var _loc13_:Sprite = null; var _loc14_:growthSprite = null; var _loc15_:Sprite = null; var _loc16_:TextField = null; var _loc17_:TextField = null; var _loc18_:TextField = null; var _loc19_:TextField = null; var _loc20_:ezButton = null; var _loc21_:ezButton = null; if(!GAMEPAUSED) { pause(); } if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); _loc2_ = new Sprite(); _loc2_.graphics.beginFill(0); _loc2_.graphics.drawRect(0,0,400,300); _loc2_.graphics.endFill(); _loc2_.graphics.beginFill(3355443); _loc2_.graphics.drawRect(2,2,396,296); _loc2_.graphics.endFill(); _loc2_.x = 100; _loc2_.y = 150; _loc3_ = new_tf("title"); _loc3_.x = 70; _loc3_.y = 30; _loc3_.width = 275; _loc3_.text = "Instructions"; _loc2_.addChild(_loc3_); (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify"; _loc4_.x = 25; _loc4_.y = 90; _loc4_.width = 350; _loc4_.height = 250; _loc4_.multiline = true; _loc4_.wordWrap = true; _loc5_ = "Press down on the mouse to create a filler ball. It will continue to grow until..."; _loc4_.htmlText = _loc5_; _loc2_.addChild(_loc4_); addChild(body); body.addChild(_loc2_); _loc7_ = (_loc6_ = new constantVSprite(0,0)).sprite; _loc9_ = (_loc8_ = new growthSprite(0,0,30,16777215)).sprite; _loc2_.addChild(_loc7_); _loc2_.addChild(_loc9_); _loc7_.x = 320; _loc9_.x = 80; _loc7_.y = 175; _loc9_.y = 175; _loc11_ = (_loc10_ = new growthSprite(0,0,20,16777215)).sprite; _loc13_ = (_loc12_ = new growthSprite(0,0,20,16777215)).sprite; _loc15_ = (_loc14_ = new growthSprite(0,0,20,16777215)).sprite; _loc2_.addChild(_loc11_); _loc2_.addChild(_loc13_); _loc11_.x = 180; _loc11_.y = 205; _loc13_.x = 220; _loc13_.y = 205; _loc2_.addChild(_loc15_); _loc15_.x = 290; _loc15_.y = 175; (_loc16_ = new_tf("center")).x = 5; _loc16_.y = 205; _loc16_.width = 150; _loc16_.text = "...you release\nthe mouse"; _loc2_.addChild(_loc16_); (_loc17_ = new_tf("center")).x = 230; _loc17_.y = 205; _loc17_.width = 150; _loc17_.text = "...you run into\na bouncy ball"; _loc2_.addChild(_loc17_); (_loc18_ = new_tf("center")).x = 125; _loc18_.y = 145; _loc18_.width = 150; _loc18_.text = "...you run into\na filler ball"; _loc2_.addChild(_loc18_); (_loc19_ = new_tf("center")).x = 260; _loc19_.y = 145; _loc19_.width = 150; _loc19_.text = "OUCH!"; _loc2_.addChild(_loc19_); _loc2_.graphics.lineStyle(1,0,1); _loc2_.graphics.beginFill(7798784); _loc2_.graphics.drawRect(260,135,100,70); _loc2_.graphics.endFill(); _loc20_ = new ezButton("Next","inst_2",80,25); _loc21_ = new ezButton("Start","skip_instructions",80,25); _loc2_.addChild(_loc20_); _loc20_.x = 200; _loc20_.y = 260; _loc2_.addChild(_loc21_); _loc21_.x = 115; _loc21_.y = 260; _loc21_.addEventListener("button_skip_instructions",dismissOverlay); _loc20_.addEventListener("button_inst_2",showInstructions3); } private function showRoundup(param1:Event = null) : void { } public function init(param1:Boolean) : void { var _loc2_:shadowRectParticle = null; var _loc3_:shadowRectParticle = null; var _loc4_:shadowRectParticle = null; var _loc5_:shadowRectParticle = null; MochiBot.track(this,"446d3202"); kongregate = new KongregateAPI(); addChild(kongregate); kongregate.addEventListener(KongregateEvent.COMPLETE,kongConnected); bg = new Sprite(); bg.graphics.beginFill(5592405); bg.graphics.drawRect(0,0,600,500); bg.graphics.endFill(); addChild(bg); stage.frameRate = 45; addEventListener(Event.ENTER_FRAME,run); rollOverSound = new rollOverMp3(); addEventListener("sound_rollover",buttonSound); alert05Sound = new modAlert05Mp3(); alert24Sound = new modAlert24Mp3(); bounceSound = new boopMp3(); thudSound = new thudMp3(); flingSound = new flingMp3(); APEngine.init(1 / 4); APEngine.damping = 1; APEngine.container = this; world = new Group(); player = new Group(); bouncyBalls = new Group(); fillerBalls = new Group(); _loc2_ = new shadowRectParticle(595,300,10,400,0,true,1,0.25); _loc3_ = new shadowRectParticle(300,495,600,10,0,true,1,0.25); _loc4_ = new shadowRectParticle(300,105,600,10,0,true,1,0.25); _loc5_ = new shadowRectParticle(5,300,10,400,0,true,1,0.25); _loc2_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp); _loc5_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp); _loc3_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp); _loc4_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp); world.addParticle(_loc2_); world.addParticle(_loc5_); world.addParticle(_loc4_); world.addParticle(_loc3_); player.addCollidable(world); bouncyBalls.addCollidable(world); fillerBalls.addCollidable(world); bouncyBalls.addCollidable(fillerBalls); bouncyBalls.collideInternal = true; fillerBalls.collideInternal = true; APEngine.addGroup(world); APEngine.addGroup(player); APEngine.addGroup(bouncyBalls); APEngine.addGroup(fillerBalls); bg.addEventListener(MouseEvent.MOUSE_DOWN,mouseDown); bg.addEventListener(MouseEvent.MOUSE_UP,mouseUp); drawUI(); musicSound = new musicMp3(); logoSprite = new kongLogo() as DisplayObject; splashSprite = new kongSplash() as DisplayObject; showKongSplash(); } public function configureOverlays() : void { var _loc1_:Sprite = null; var _loc2_:TextField = null; var _loc3_:TextField = null; var _loc4_:int = 0; var _loc5_:int = 0; var _loc6_:int = 0; var _loc7_:int = 0; var _loc8_:int = 0; var _loc9_:TextField = null; var _loc10_:TextField = null; if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); _loc1_ = new Sprite(); _loc1_.graphics.beginFill(0); _loc1_.graphics.drawRect(0,0,360,300); _loc1_.graphics.endFill(); _loc1_.graphics.beginFill(3355443); _loc1_.graphics.drawRect(2,2,356,296); _loc1_.graphics.endFill(); _loc1_.x = 130; _loc1_.y = 150; _loc2_ = new_tf("title"); _loc2_.x = 50; _loc2_.y = 30; _loc2_.width = 275; _loc2_.text = "Level Complete!"; _loc1_.addChild(_loc2_); _loc3_ = new_tf("right"); _loc3_.x = 10; _loc3_.y = 90; _loc3_.width = 200; _loc3_.height = 300; _loc3_.htmlText = "Completion Bonus:\n Lives Bonus:\n Time Bonus:\n Balls Left Bonus: \n\n <b>Total Bonus:"; _loc1_.addChild(_loc3_); _loc4_ = Math.max(0,Math.round((percentFilled - 66.6) * (CURRENTLEVEL + 5) * 4)); _loc5_ = livesLeft * 25; _loc6_ = Math.floor(timeLeft / 1000); _loc7_ = ballsLeft * 5; _loc8_ = _loc4_ + _loc5_ + _loc6_ + _loc7_; playerScore += _loc8_; if(playerScore > 40000 && Send40K) { Send40K = false; kongregate.stats.submit("40K Points",1); } scoreText.text = "Score: " + playerScore; (_loc9_ = new_tf("right")).x = 160; _loc9_.y = 90; _loc9_.width = 100; _loc9_.height = 300; _loc9_.htmlText = _loc4_ + "\n" + _loc5_ + "\n" + _loc6_ + "\n" + _loc7_ + "\n\n<b>" + _loc8_ + "</b>"; _loc1_.addChild(_loc9_); addChild(body); body.addChild(_loc1_); (_loc10_ = new_tf("center")).x = 115; _loc10_.y = 200; _loc10_.width = 150; _loc10_.htmlText = "<font size=\'size:8px\'>(Click to Continue)</font>"; _loc1_.addChild(_loc10_); createKongSprite(); body.addChild(kongSprite); kongSprite.x = _loc1_.x + 10; kongSprite.y = _loc1_.y + 235; kongSprite.buttonMode = true; kongSprite.addEventListener("click",goToKongregate); _loc1_.mouseChildren = false; _loc1_.addEventListener("click",nextLevel); fadeBody(); } public function showInstructions3(param1:Event = null) : void { var _loc2_:Sprite = null; var _loc3_:TextField = null; var _loc4_:TextField = null; var _loc5_:String = null; var _loc6_:TextField = null; var _loc7_:String = null; var _loc8_:int = 0; var _loc9_:ezButton = null; var _loc10_:ezButton = null; var _loc11_:growthSprite = null; var _loc12_:Sprite = null; var _loc13_:growthSprite = null; var _loc14_:Sprite = null; if(!GAMEPAUSED) { pause(); } if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); _loc2_ = new Sprite(); _loc2_.graphics.beginFill(0); _loc2_.graphics.drawRect(0,0,400,300); _loc2_.graphics.endFill(); _loc2_.graphics.beginFill(3355443); _loc2_.graphics.drawRect(2,2,396,296); _loc2_.graphics.endFill(); _loc2_.x = 100; _loc2_.y = 150; _loc3_ = new_tf("title"); _loc3_.x = 70; _loc3_.y = 30; _loc3_.width = 275; _loc3_.text = "Instructions"; _loc2_.addChild(_loc3_); (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify"; _loc4_.x = 25; _loc4_.y = 90; _loc4_.width = 350; _loc4_.height = 250; _loc4_.multiline = true; _loc4_.wordWrap = true; _loc5_ = "You get a limited number of both lives and balls each round."; _loc4_.htmlText = _loc5_; _loc2_.addChild(_loc4_); (_loc6_ = new_tf("left")).defaultTextFormat.align = "justify"; _loc6_.x = 25; _loc6_.y = 220; _loc6_.width = 350; _loc6_.height = 250; _loc6_.multiline = true; _loc6_.wordWrap = true; _loc7_ = "If you run out of balls, each new ball will cost you a life."; _loc6_.htmlText = _loc7_; _loc2_.addChild(_loc6_); addChild(body); body.addChild(_loc2_); _loc8_ = 0; while(_loc8_ < 9) { _loc12_ = (_loc11_ = new growthSprite(0,0,20,16777215)).sprite; _loc2_.addChild(_loc12_); _loc12_.x = 40 + 40 * _loc8_; _loc12_.y = 190; _loc14_ = (_loc13_ = new growthSprite(0,0,20,16777215)).sprite; _loc2_.addChild(_loc14_); _loc14_.x = 40 + 40 * _loc8_; _loc14_.y = 150; _loc8_++; } _loc9_ = new ezButton("Next","inst_2",80,25); _loc10_ = new ezButton("Start","skip_instructions",80,25); _loc2_.addChild(_loc9_); _loc9_.x = 200; _loc9_.y = 260; _loc2_.addChild(_loc10_); _loc10_.x = 115; _loc10_.y = 260; _loc10_.addEventListener("button_skip_instructions",dismissOverlay); _loc9_.addEventListener("button_inst_2",showInstructions4); } public function showInstructions4(param1:Event = null) : void { var _loc2_:Sprite = null; var _loc3_:TextField = null; var _loc4_:TextField = null; var _loc5_:String = null; var _loc6_:ezButton = null; if(!GAMEPAUSED) { pause(); } if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); _loc2_ = new Sprite(); _loc2_.graphics.beginFill(0); _loc2_.graphics.drawRect(0,0,400,300); _loc2_.graphics.endFill(); _loc2_.graphics.beginFill(3355443); _loc2_.graphics.drawRect(2,2,396,296); _loc2_.graphics.endFill(); _loc2_.x = 100; _loc2_.y = 150; _loc3_ = new_tf("title"); _loc3_.x = 70; _loc3_.y = 30; _loc3_.width = 275; _loc3_.text = "Instructions"; _loc2_.addChild(_loc3_); (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify"; _loc4_.x = 25; _loc4_.y = 90; _loc4_.width = 350; _loc4_.height = 250; _loc4_.multiline = true; _loc4_.wordWrap = true; _loc5_ = "At the end of each level, you will earn bonuses for: \n\n *Filling more than 2/3 of the level\n *Number of lives remaining\n *Time remaining\n *Balls remaining\n\nThe timer is only used for bonus, so don\'t worry about it running down to zero!"; _loc4_.htmlText = _loc5_; _loc2_.addChild(_loc4_); addChild(body); body.addChild(_loc2_); _loc6_ = new ezButton("Start","skip_instructions",80,25); _loc2_.addChild(_loc6_); _loc6_.x = 155; _loc6_.y = 260; _loc6_.addEventListener("button_skip_instructions",dismissOverlay); } private function fadeHandler(param1:TimerEvent) : void { ++slideCount; body.alpha = slideCount / 40; } public function postSplash() : void { startLevel(1); showInstructions(); bg.removeChild(pauseText); } private function toggleMusic(param1:Event = null) : void { if(MUSICENABLED) { MUSICENABLED = false; stopMusic(); param1.target.label = "Music On"; } else { MUSICENABLED = true; startMusic(); param1.target.label = "Music Off"; } } private function checkSponsorLock() : void { var _loc1_:Sprite = null; var _loc2_:TextField = null; if(GAMEPAUSED) { return; } if(getTimer() < 300000) { return; } GAMEPAUSED = true; if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); body.x = 0; body.y = 0; addChild(body); _loc1_ = new Sprite(); _loc1_.graphics.beginFill(0,0.5); _loc1_.graphics.drawRect(0,0,600,500); _loc1_.graphics.endFill(); body.addChild(_loc1_); _loc2_ = new_tf("center"); _loc2_.text = "This game has not yet been released. If you would like \n"; _loc2_.appendText("to sponsor it, send an email to learnyourabcs@gmail.com."); _loc2_.width = 400; _loc2_.x = 100; _loc2_.y = 200; body.addChild(_loc2_); fadeBody(); } public function showInstructions(param1:Event = null) : void { var _loc2_:Sprite = null; var _loc3_:TextField = null; var _loc4_:TextField = null; var _loc5_:* = null; var _loc6_:constantVSprite = null; var _loc7_:Sprite = null; var _loc8_:growthSprite = null; var _loc9_:Sprite = null; var _loc10_:TextField = null; var _loc11_:TextField = null; var _loc12_:ezButton = null; var _loc13_:ezButton = null; if(!GAMEPAUSED) { pause(); } if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); _loc2_ = new Sprite(); _loc2_.graphics.beginFill(0); _loc2_.graphics.drawRect(0,0,400,300); _loc2_.graphics.endFill(); _loc2_.graphics.beginFill(3355443); _loc2_.graphics.drawRect(2,2,396,296); _loc2_.graphics.endFill(); _loc2_.x = 100; _loc2_.y = 150; _loc3_ = new_tf("title"); _loc3_.x = 70; _loc3_.y = 30; _loc3_.width = 275; _loc3_.text = "Instructions"; _loc2_.addChild(_loc3_); (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify"; _loc4_.x = 25; _loc4_.y = 90; _loc4_.width = 350; _loc4_.height = 250; _loc4_.multiline = true; _loc4_.wordWrap = true; _loc5_ = (_loc5_ = "The goal of <b>filler</b> is to fill up 2/3 of the screen while ") + "avoiding the bouncing balls."; _loc4_.htmlText = _loc5_; _loc2_.addChild(_loc4_); addChild(body); body.addChild(_loc2_); _loc7_ = (_loc6_ = new constantVSprite(0,0)).sprite; _loc9_ = (_loc8_ = new growthSprite(0,0,30,16777215)).sprite; _loc2_.addChild(_loc7_); _loc2_.addChild(_loc9_); _loc7_.x = 290; _loc9_.x = 100; _loc7_.y = 185; _loc9_.y = 185; (_loc10_ = new_tf("center")).x = 25; _loc10_.y = 225; _loc10_.width = 150; _loc10_.text = "filler ball = good"; _loc2_.addChild(_loc10_); (_loc11_ = new_tf("center")).x = 210; _loc11_.y = 225; _loc11_.width = 150; _loc11_.text = "bouncy ball = bad"; _loc2_.addChild(_loc11_); _loc12_ = new ezButton("Next","inst_2",80,25); _loc13_ = new ezButton("Start","skip_instructions",80,25); _loc2_.addChild(_loc12_); _loc12_.x = 200; _loc12_.y = 260; _loc2_.addChild(_loc13_); _loc13_.x = 115; _loc13_.y = 260; _loc13_.addEventListener("button_skip_instructions",dismissOverlay); _loc12_.addEventListener("button_inst_2",showInstruction2); if(getTimer() > 30000) { fadeBody(); } } public function stopMusic() : void { if(musicChannel) { musicChannel.stop(); } } public function tallyPercent() : void { var _loc1_:Array = null; var _loc2_:Number = NaN; var _loc3_:int = 0; var _loc4_:* = null; var _loc5_:SoundTransform = null; _loc1_ = fillerBalls.getAll(); _loc2_ = 0; _loc3_ = 0; while(_loc3_ < _loc1_.length) { _loc2_ += 3.1415 * _loc1_[_loc3_].radius * _loc1_[_loc3_].radius; _loc3_++; } percentFilled = _loc2_ / MAXAREA * 100; if((_loc4_ = Math.round(_loc2_ / MAXAREA * 1000) / 10 + "").indexOf(".") == -1) { _loc4_ += ".0"; } pctText.text = _loc4_ + "% cleared"; if(_loc2_ / MAXAREA * 100 >= 66.555) { if(CURRENTLEVEL == 3) { kongregate.stats.submit("Cleared Level 3",1); } HighestPercentFilled = Math.max(HighestPercentFilled,_loc2_ / MAXAREA * 100); GAMEPAUSED = true; configureOverlays(); _loc5_ = new SoundTransform(0.5); if(SOUNDENABLED) { alert24Sound.play(0,0,_loc5_); } } } public function createKongSprite() : void { var _loc1_:TextFormat = null; var _loc2_:Sprite = null; var _loc3_:TextField = null; _loc1_ = new TextFormat(); _loc1_.font = "Arial"; _loc1_.color = 16777215; _loc1_.size = 10; _loc2_ = new Sprite(); _loc2_.mouseChildren = false; _loc2_.graphics.beginFill(0); _loc2_.graphics.lineStyle(1,16777215,1); _loc2_.graphics.drawRect(0,15,340,40); _loc2_.graphics.endFill(); _loc2_.addChild(logoSprite); logoSprite.x = 0; logoSprite.y = 0; _loc3_ = new_tf("left"); _loc3_.defaultTextFormat = _loc1_; _loc3_.text = "Sponsored by:"; _loc2_.addChild(_loc3_); _loc3_.x = 0; _loc3_.y = 16; _loc1_.size = 12; kongText = new_tf("left"); kongText.width = 300; kongText.defaultTextFormat = _loc1_; kongText.text = "Play more games on Kongregate\nto chat and earn badges!"; _loc2_.addChild(kongText); kongText.x = 155; kongText.y = 19; kongSprite = _loc2_; } public function kongConnected(param1:KongregateEvent) : void { trace("Succesfully connected to Kongregate API"); } private function redTimerHandler(param1:TimerEvent) : void { var _loc2_:Number = NaN; var _loc3_:int = 0; var _loc4_:uint = 0; var _loc5_:uint = 0; var _loc6_:uint = 0; ++redCount; _loc2_ = redCount / 20; _loc3_ = _loc2_ * 85; bg.graphics.clear(); _loc4_ = uint(85 << 16); _loc5_ = uint(_loc3_ << 8); _loc6_ = uint(_loc3_); bg.graphics.beginFill(_loc4_ + _loc5_ + _loc6_); bg.graphics.drawRect(0,0,600,500); bg.graphics.endFill(); } public function sendHighScore(param1:Object = null) : void { var TX:int = 0; var scoreBG:Sprite = null; var table:TextScoreTable = null; var format:TextFormat = null; var scoreLabel:TextField = null; var nameLabel:TextField = null; var scoreText:TextField = null; var nameField:TextField = null; var submit:ezButton = null; var ng:ezButton = null; var doneWithScores:ezButton = null; var sendScore:Function = null; var ev:Object = param1; if(GAMEPAUSED) { pause(); } GAMEPAUSED = true; stopMusic(); kongregate.scores.submit(playerScore); kongregate.stats.submit("Filler Balls Created",TotalBallsMade); kongregate.stats.submit("Highest Level",CURRENTLEVEL); kongregate.stats.submit("Highest Percent",HighestPercentFilled); if(body) { if(contains(body)) { removeChild(body); } body = null; } body = new MovieClip(); body.x = 0; body.y = 0; addChild(body); TX = 125; scoreBG = new Sprite(); scoreBG.graphics.beginFill(0); scoreBG.graphics.drawRect(TX - 5,150,360,300); scoreBG.graphics.endFill(); scoreBG.graphics.beginFill(3355443); scoreBG.graphics.drawRect(TX - 3,152,356,296); scoreBG.graphics.endFill(); body.addChild(scoreBG); table = new TextScoreTable(); trace("table created..."); body.addChild(table); table.x = TX; table.y = 155; table.init(); table.title.text = " Game Over! "; format = new TextFormat(); format.font = "Arial"; format.color = 16777215; format.size = 16; scoreLabel = new TextField(); scoreLabel.defaultTextFormat = format; scoreLabel.selectable = false; scoreLabel.text = "Your Score:"; scoreLabel.x = TX + 55; scoreLabel.y = 260; body.addChild(scoreLabel); nameLabel = new TextField(); nameLabel.defaultTextFormat = format; nameLabel.selectable = false; nameLabel.text = "Your Name:"; nameLabel.x = TX + 55; nameLabel.y = 280; body.addChild(nameLabel); scoreText = new TextField(); scoreText.defaultTextFormat = format; scoreText.selectable = false; scoreText.text = TextScoreTable.commafy(playerScore); scoreText.x = TX + 158; scoreText.y = 260; scoreText.width = 120; body.addChild(scoreText); nameField = new TextField(); nameField.defaultTextFormat = format; nameField.text = playerName; nameField.x = TX + 158; nameField.y = 280; nameField.width = 120; nameField.height = 22; nameField.border = true; nameField.type = TextFieldType.INPUT; body.addChild(nameField); submit = new ezButton("Submit","hsSubmit",100,36); submit.x = TX + 176; submit.y = 340; body.addChild(submit); ng = new ezButton("New Game","newGame",100,36); ng.x = TX + 74; ng.y = 340; body.addChild(ng); ng.addEventListener("button_newGame",newGameButton); doneWithScores = new ezButton("New Game","closeScoresAndNew",100,36); doneWithScores.x = TX + 245; doneWithScores.y = 405; doneWithScores.visible = false; body.addChild(doneWithScores); doneWithScores.addEventListener("button_closeScoresAndNew",closeScoresNew); sendScore = function(param1:Event):void { var opts:Object = null; var hs:String = null; var params:Object = null; var event:Event = param1; shrinkKongSprite(); submit.visible = false; ng.visible = false; nameField.visible = false; nameLabel.visible = false; scoreLabel.visible = false; scoreText.visible = false; doneWithScores.visible = true; playerName = nameField.text; opts = getOptions(); hs = "/kong2"; try { params = root.loaderInfo.parameters; if(params["hsname"]) { hs = String(params["hsname"]); } } catch(error:Error) { trace("Whoops!"); } opts.id += hs; opts.name = playerName; opts.score = playerScore; table.reset("Sending high score..."); MochiAd.sendHighScore(opts,table,"gotScores"); }; submit.addEventListener("button_hsSubmit",sendScore); createKongSprite(); kongSprite.x = TX + 5; kongSprite.y = 385; kongSprite.buttonMode = true; kongSprite.addEventListener("click",goToKongregate); body.addChild(kongSprite); } public function new_tf(param1:String) : TextField { var _loc2_:TextField = null; _loc2_ = new TextField(); _loc2_.defaultTextFormat = scoreTextFormat(param1); _loc2_.selectable = false; return _loc2_; } public function hardBounceSound(param1:Event) : void { var _loc2_:SoundTransform = null; if(!SOUNDENABLED) { return; } _loc2_ = new SoundTransform(0.75); bounceSound.play(0,0,_loc2_); } private function newGameButton(param1:Event = null) : void { hideMenu(); if(Boolean(body) && contains(body)) { removeChild(body); } if(getTimer() - LASTAD > 900000) { showInterLevel(); } else { newGame(); } } public function playBounceSound(param1:Event) : void { var _loc2_:SoundTransform = null; if(!SOUNDENABLED) { return; } _loc2_ = new SoundTransform(0.4); bounceSound.play(0,0,_loc2_); } public function newGame(param1:Event = null) : void { if(GAMEPAUSED) { pause(); } startMusic(); playerScore = 0; scoreText.text = "Score: 0"; CURRENTLEVEL = 1; TotalBallsMade = 0; startLevel(1); } public function showKongSplash() : void { var _loc1_:Sprite = null; if(Boolean(body) && contains(body)) { removeChild(body); } body = new MovieClip(); body.x = 0; body.y = 0; addChild(body); _loc1_ = new Sprite(); _loc1_.graphics.beginFill(0,1); _loc1_.graphics.drawRect(0,0,600,500); _loc1_.graphics.endFill(); _loc1_.buttonMode = true; body.addChild(_loc1_); _loc1_.addChild(splashSprite); splashSprite.width = 600; splashSprite.height = 500; _loc1_.mouseChildren = false; _loc1_.addEventListener("click",goToKongregate); setTimeout(postSplash,3250); } private function scoreTextFormat(param1:String) : TextFormat { var _loc2_:TextFormat = null; _loc2_ = new TextFormat(); _loc2_.font = "_sans"; _loc2_.color = 13421772; _loc2_.size = 14; if(param1 == "left") { _loc2_.align = TextFormatAlign.LEFT; } else if(param1 == "right") { _loc2_.align = TextFormatAlign.RIGHT; } else if(param1 == "center") { _loc2_.align = TextFormatAlign.CENTER; } else { if(param1 != "title") { throw new Error("Invalid text format " + param1); } _loc2_.align = TextFormatAlign.CENTER; _loc2_.color = 16777215; _loc2_.size = 32; } return _loc2_; } private function fadeHandlerDone(param1:TimerEvent) : void { body.alpha = 100; } public function goToKongregate(param1:Event) : void { var _loc2_:URLRequest = null; _loc2_ = new URLRequest("http://www.kongregate.com/?gamereferral=filler"); navigateToURL(_loc2_,"_blank"); } private function hideMenu(param1:Event = null) : void { verticalMenu.visible = false; } private function pause(param1:Event = null) : void { if(GAMEPAUSED) { if(Boolean(body) && contains(body)) { return; } GAMEPAUSED = false; LASTUPDATE = getTimer(); if(bg.contains(pauseOverlay)) { bg.removeChild(pauseOverlay); } if(bg.contains(pauseText)) { bg.removeChild(pauseText); } startMusic(); } else { GAMEPAUSED = true; bg.addChild(pauseOverlay); bg.addChild(pauseText); stopMusic(); } } } }