home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / filler.swf / scripts / filler.as < prev    next >
Encoding:
Text File  |  2008-09-02  |  56.5 KB  |  1,770 lines

  1. package
  2. {
  3.    import com.kongregate.as3.client.*;
  4.    import com.kongregate.as3.client.events.*;
  5.    import com.mochi.*;
  6.    import com.simianlogic.*;
  7.    import flash.display.DisplayObject;
  8.    import flash.display.MovieClip;
  9.    import flash.display.Sprite;
  10.    import flash.events.Event;
  11.    import flash.events.MouseEvent;
  12.    import flash.events.TimerEvent;
  13.    import flash.media.Sound;
  14.    import flash.media.SoundChannel;
  15.    import flash.media.SoundTransform;
  16.    import flash.net.*;
  17.    import flash.text.*;
  18.    import flash.utils.Timer;
  19.    import flash.utils.getTimer;
  20.    import flash.utils.setTimeout;
  21.    import org.cove.ape.*;
  22.    
  23.    public dynamic class filler extends Sprite
  24.    {
  25.       
  26.       public static const MAXAREA:int = 230100;
  27.       
  28.       public static const COLORLIST:Array = [3394815,3407718,16763955,13382655,4060416,47349,3997941,10092400,15861];
  29.       
  30.       public static var GAME_OPTIONS:Object = {
  31.          "id":"74eaa3b8c08bf451",
  32.          "res":"600x500"
  33.       };
  34.        
  35.       
  36.       public var verticalMenu:Sprite;
  37.       
  38.       public var percentFilled:Number;
  39.       
  40.       private var splashSprite:DisplayObject;
  41.       
  42.       public var timerText:TextField;
  43.       
  44.       private var modAlert24Mp3:Class;
  45.       
  46.       public var activeBall:growthSprite;
  47.       
  48.       private var playerScore:int = 0;
  49.       
  50.       private var rollOverMp3:Class;
  51.       
  52.       public var soundOverlay:Sprite;
  53.       
  54.       public var pauseText:TextField;
  55.       
  56.       public var bg:Sprite;
  57.       
  58.       private var logoSprite:DisplayObject;
  59.       
  60.       public var timeLeft:Number;
  61.       
  62.       public var ballsLeft:Number;
  63.       
  64.       public var soundOptions:Array;
  65.       
  66.       private var musicMp3:Class;
  67.       
  68.       private var rollOverSound:Sound;
  69.       
  70.       private var Send40K:Boolean = true;
  71.       
  72.       public var fillerBalls:Group;
  73.       
  74.       private var TotalBallsMade:int = 0;
  75.       
  76.       private var thudSound:Sound;
  77.       
  78.       public var levelText:TextField;
  79.       
  80.       public var livesText:TextField;
  81.       
  82.       public var LASTUPDATE:int;
  83.       
  84.       public var player:Group;
  85.       
  86.       public var scoreText:TextField;
  87.       
  88.       public var kongText:TextField;
  89.       
  90.       private var kongSplash:Class;
  91.       
  92.       public var redCount:int = 0;
  93.       
  94.       private var alert24Sound:Sound;
  95.       
  96.       private var flingSound:Sound;
  97.       
  98.       private var playerName:String = "<your name>";
  99.       
  100.       private var musicChannel:SoundChannel;
  101.       
  102.       private var boopMp3:Class;
  103.       
  104.       private var alert05Sound:Sound;
  105.       
  106.       public var bouncyBalls:Group;
  107.       
  108.       public var LASTAD:int = 0;
  109.       
  110.       public var kongSprite:Sprite;
  111.       
  112.       public var SOUNDENABLED:Boolean = true;
  113.       
  114.       private var bounceSound:Sound;
  115.       
  116.       private var kongLogo:Class;
  117.       
  118.       private var modAlert05Mp3:Class;
  119.       
  120.       public var pauseOverlay:Sprite;
  121.       
  122.       public var MUSICENABLED:Boolean = true;
  123.       
  124.       public var world:Group;
  125.       
  126.       public var GAMEPAUSED:Boolean = false;
  127.       
  128.       private var body:MovieClip = null;
  129.       
  130.       public var CURRENTLEVEL:int = 1;
  131.       
  132.       public var livesLeft:Number;
  133.       
  134.       public var pctText:TextField;
  135.       
  136.       public var ballText:TextField;
  137.       
  138.       private var kongregate:KongregateAPI;
  139.       
  140.       public var slideCount:int;
  141.       
  142.       private var HighestPercentFilled:Number = 0;
  143.       
  144.       private var thudMp3:Class;
  145.       
  146.       private var musicSound:Sound;
  147.       
  148.       private var flingMp3:Class;
  149.       
  150.       public function filler()
  151.       {
  152.          kongLogo = filler_kongLogo;
  153.          kongSplash = filler_kongSplash;
  154.          musicMp3 = filler_musicMp3;
  155.          flingMp3 = filler_flingMp3;
  156.          rollOverMp3 = filler_rollOverMp3;
  157.          modAlert05Mp3 = filler_modAlert05Mp3;
  158.          modAlert24Mp3 = filler_modAlert24Mp3;
  159.          boopMp3 = filler_boopMp3;
  160.          thudMp3 = filler_thudMp3;
  161.          TotalBallsMade = 0;
  162.          HighestPercentFilled = 0;
  163.          Send40K = true;
  164.          body = null;
  165.          CURRENTLEVEL = 1;
  166.          GAMEPAUSED = false;
  167.          SOUNDENABLED = true;
  168.          MUSICENABLED = true;
  169.          LASTAD = 0;
  170.          playerName = "<your name>";
  171.          playerScore = 0;
  172.          redCount = 0;
  173.          soundOptions = [1,1,1,1];
  174.          super();
  175.          if(stage != null)
  176.          {
  177.             init(false);
  178.          }
  179.       }
  180.       
  181.       private function showMenu(param1:Event = null) : void
  182.       {
  183.          verticalMenu.visible = true;
  184.       }
  185.       
  186.       private function freezeActiveBall() : void
  187.       {
  188.          var _loc1_:Array = null;
  189.          var _loc2_:growthSprite = null;
  190.          _loc1_ = player.getAll();
  191.          if(_loc1_.length > 0 && _loc1_[0] == activeBall)
  192.          {
  193.             player.removeParticle(activeBall);
  194.          }
  195.          _loc2_ = new growthSprite(activeBall.position.x,activeBall.position.y,activeBall.radius,13421772);
  196.          fillerBalls.addParticle(_loc2_);
  197.          if(SOUNDENABLED)
  198.          {
  199.          }
  200.          playerScore += Math.round(3.1415 * activeBall.radius * activeBall.radius / 100);
  201.          if(playerScore > 40000 && Send40K)
  202.          {
  203.             Send40K = false;
  204.             kongregate.stats.submit("40K Points",1);
  205.          }
  206.          scoreText.text = "Score: " + playerScore;
  207.          tallyPercent();
  208.          if(percentFilled >= 66.555)
  209.          {
  210.             return;
  211.          }
  212.          ++TotalBallsMade;
  213.          --ballsLeft;
  214.          if(ballsLeft < 0)
  215.          {
  216.             ouch();
  217.          }
  218.          ballsLeft = Math.max(ballsLeft,0);
  219.          ballText.text = "Balls: " + ballsLeft;
  220.       }
  221.       
  222.       private function mouseUp(param1:Event) : void
  223.       {
  224.          var _loc2_:Array = null;
  225.          _loc2_ = player.getAll();
  226.          if(_loc2_.length > 0 && _loc2_[0] == activeBall)
  227.          {
  228.             freezeActiveBall();
  229.          }
  230.       }
  231.       
  232.       public function shrinkKongSprite() : void
  233.       {
  234.          kongSprite.graphics.clear();
  235.          kongSprite.graphics.beginFill(0);
  236.          kongSprite.graphics.lineStyle(1,16777215,1);
  237.          kongSprite.graphics.drawRect(0,15,151,40);
  238.          kongSprite.graphics.endFill();
  239.          kongText.visible = false;
  240.       }
  241.       
  242.       public function fadeBody() : void
  243.       {
  244.          var _loc1_:Timer = null;
  245.          if(!body || !contains(body))
  246.          {
  247.             return;
  248.          }
  249.          _loc1_ = new Timer(10,40);
  250.          _loc1_.addEventListener("timer",fadeHandler);
  251.          _loc1_.addEventListener("timerComplete",fadeHandlerDone);
  252.          slideCount = 0;
  253.          body.alpha = 0;
  254.          _loc1_.start();
  255.       }
  256.       
  257.       private function redTimerHandlerDone(param1:TimerEvent) : void
  258.       {
  259.          bg.graphics.clear();
  260.          bg.graphics.beginFill(5592405);
  261.          bg.graphics.drawRect(0,0,600,500);
  262.          bg.graphics.endFill();
  263.       }
  264.       
  265.       private function startLevel(param1:int) : void
  266.       {
  267.          var _loc2_:int = 0;
  268.          var _loc3_:Array = null;
  269.          var _loc4_:Array = null;
  270.          var _loc5_:int = 0;
  271.          var _loc6_:constantVSprite = null;
  272.          if(Boolean(body) && contains(body))
  273.          {
  274.             removeChild(body);
  275.          }
  276.          if(GAMEPAUSED)
  277.          {
  278.             pause();
  279.          }
  280.          livesLeft = param1 + 1;
  281.          timeLeft = (60 + param1 * 30) * 1000;
  282.          ballsLeft = 18 + 2 * param1;
  283.          _loc2_ = 4.5;
  284.          _loc3_ = [new Vector(-_loc2_,-_loc2_),new Vector(_loc2_,-_loc2_),new Vector(_loc2_,_loc2_),new Vector(-_loc2_,_loc2_)];
  285.          _loc4_ = bouncyBalls.getAll();
  286.          _loc5_ = 0;
  287.          while(_loc5_ < _loc4_.length)
  288.          {
  289.             bouncyBalls.removeParticle(_loc4_[_loc5_]);
  290.             _loc5_++;
  291.          }
  292.          _loc4_ = fillerBalls.getAll();
  293.          _loc5_ = 0;
  294.          while(_loc5_ < _loc4_.length)
  295.          {
  296.             fillerBalls.removeParticle(_loc4_[_loc5_]);
  297.             _loc5_++;
  298.          }
  299.          _loc5_ = 0;
  300.          while(_loc5_ < param1 + 1)
  301.          {
  302.             (_loc6_ = new constantVSprite(Math.random() * 500 + 50,Math.random() * 350 + 125)).setVelocity(_loc3_[int(Math.random() * 3.9999)]);
  303.             bouncyBalls.addParticle(_loc6_);
  304.             _loc5_++;
  305.          }
  306.          pctText.text = "0% cleared";
  307.          levelText.text = "Level: " + param1;
  308.          livesText.text = "Lives: " + livesLeft;
  309.          timerText.text = "Time left: " + Math.round(timeLeft / 100);
  310.          timerText.x = 600 - (timerText.textWidth + 5);
  311.          ballText.text = "Balls: " + ballsLeft;
  312.          LASTUPDATE = getTimer();
  313.       }
  314.       
  315.       public function nextLevel(param1:Event = null) : void
  316.       {
  317.          if(CURRENTLEVEL == 5)
  318.          {
  319.             kongregate.stats.submit("Games Past Level 5",1);
  320.          }
  321.          if(CURRENTLEVEL == 10)
  322.          {
  323.             kongregate.stats.submit("Games Past Level 10",1);
  324.          }
  325.          if(CURRENTLEVEL == 15)
  326.          {
  327.             kongregate.stats.submit("Games Past Level 15",1);
  328.          }
  329.          if(CURRENTLEVEL == 20)
  330.          {
  331.             kongregate.stats.submit("Games Past Level 20",1);
  332.          }
  333.          if(CURRENTLEVEL == 25)
  334.          {
  335.             kongregate.stats.submit("Games Past Level 25",1);
  336.          }
  337.          ++CURRENTLEVEL;
  338.          startLevel(CURRENTLEVEL);
  339.       }
  340.       
  341.       public function dismissOverlay(param1:Event = null) : void
  342.       {
  343.          if(body)
  344.          {
  345.             if(contains(body))
  346.             {
  347.                removeChild(body);
  348.             }
  349.             body = null;
  350.          }
  351.          if(livesLeft == 0)
  352.          {
  353.             newGameButton();
  354.             return;
  355.          }
  356.          if(percentFilled > 65.55)
  357.          {
  358.             nextLevel();
  359.          }
  360.          if(GAMEPAUSED)
  361.          {
  362.             pause();
  363.          }
  364.       }
  365.       
  366.       public function getOptions() : Object
  367.       {
  368.          var _loc1_:Object = null;
  369.          var _loc2_:String = null;
  370.          _loc1_ = {
  371.             "clip":body,
  372.             "id":"74eaa3b8c08bf451"
  373.          };
  374.          for(_loc2_ in GAME_OPTIONS)
  375.          {
  376.             _loc1_[_loc2_] = GAME_OPTIONS[_loc2_];
  377.          }
  378.          return _loc1_;
  379.       }
  380.       
  381.       public function flashRed() : void
  382.       {
  383.          var _loc1_:Timer = null;
  384.          bg.graphics.clear();
  385.          bg.graphics.beginFill(5592405);
  386.          bg.graphics.drawRect(0,0,600,500);
  387.          bg.graphics.endFill();
  388.          bg.graphics.beginFill(5570560);
  389.          bg.graphics.drawRect(0,100,600,400);
  390.          bg.graphics.endFill();
  391.          _loc1_ = new Timer(5,20);
  392.          _loc1_.addEventListener("timer",redTimerHandler);
  393.          _loc1_.addEventListener("timerComplete",redTimerHandlerDone);
  394.          redCount = 0;
  395.          _loc1_.start();
  396.       }
  397.       
  398.       public function getAverageSize() : int
  399.       {
  400.          var _loc1_:Array = null;
  401.          var _loc2_:Number = NaN;
  402.          var _loc3_:int = 0;
  403.          _loc1_ = fillerBalls.getAll();
  404.          _loc2_ = 0;
  405.          _loc3_ = 0;
  406.          while(_loc3_ < _loc1_.length)
  407.          {
  408.             _loc2_ += _loc1_[_loc3_].radius;
  409.             _loc3_++;
  410.          }
  411.          return Math.round(_loc2_ / _loc1_.length);
  412.       }
  413.       
  414.       private function toggleSFX(param1:Event = null) : void
  415.       {
  416.          if(SOUNDENABLED)
  417.          {
  418.             SOUNDENABLED = false;
  419.             param1.target.label = "SFX On";
  420.          }
  421.          else
  422.          {
  423.             SOUNDENABLED = true;
  424.             param1.target.label = "SFX Off";
  425.          }
  426.       }
  427.       
  428.       private function run(param1:Event) : void
  429.       {
  430.          var _loc2_:Array = null;
  431.          var _loc3_:int = 0;
  432.          var _loc4_:Array = null;
  433.          var _loc5_:constantVSprite = null;
  434.          var _loc6_:constantVSprite = null;
  435.          var _loc7_:Array = null;
  436.          var _loc8_:int = 0;
  437.          var _loc9_:SoundTransform = null;
  438.          if(GAMEPAUSED)
  439.          {
  440.             return;
  441.          }
  442.          _loc2_ = bouncyBalls.getAll();
  443.          _loc3_ = 0;
  444.          while(_loc3_ < _loc2_.length)
  445.          {
  446.             if(_loc2_[_loc3_].position.x < 0 || _loc2_[_loc3_].position.x > 600 || _loc2_[_loc3_].position.y > 500 || _loc2_[_loc3_].position.y < 100)
  447.             {
  448.                if(mouseX < 300)
  449.                {
  450.                   (_loc5_ = new constantVSprite(570,130)).setVelocity(new Vector(-4.5,4.5));
  451.                   bouncyBalls.addParticle(_loc5_);
  452.                   bouncyBalls.removeParticle(_loc2_[_loc3_]);
  453.                }
  454.                else
  455.                {
  456.                   (_loc6_ = new constantVSprite(30,130)).setVelocity(new Vector(4.5,4.5));
  457.                   bouncyBalls.addParticle(_loc6_);
  458.                   bouncyBalls.removeParticle(_loc2_[_loc3_]);
  459.                }
  460.             }
  461.             _loc3_++;
  462.          }
  463.          APEngine.step();
  464.          APEngine.paint();
  465.          timeLeft -= getTimer() - LASTUPDATE;
  466.          timeLeft = Math.max(0,timeLeft);
  467.          LASTUPDATE = getTimer();
  468.          timerText.text = "Time left: " + Math.round(timeLeft / 100);
  469.          if((_loc4_ = player.getAll()).length > 0)
  470.          {
  471.             _loc7_ = bouncyBalls.getAll();
  472.             _loc8_ = 0;
  473.             while(_loc8_ < _loc7_.length)
  474.             {
  475.                if(_loc7_[_loc8_].position.distance(activeBall.position) < activeBall.radius + _loc7_[_loc8_].radius + 0.25)
  476.                {
  477.                   player.removeParticle(activeBall);
  478.                   if(SOUNDENABLED)
  479.                   {
  480.                      _loc9_ = new SoundTransform(1.5);
  481.                      thudSound.play(0,0,_loc9_);
  482.                   }
  483.                   ouch();
  484.                   return;
  485.                }
  486.                _loc8_++;
  487.             }
  488.             if(activeBall.radius > 187.5)
  489.             {
  490.                freezeActiveBall();
  491.                return;
  492.             }
  493.             _loc7_ = fillerBalls.getAll();
  494.             _loc8_ = 0;
  495.             while(_loc8_ < _loc7_.length)
  496.             {
  497.                if(_loc7_[_loc8_].position.distance(activeBall.position) < activeBall.radius + _loc7_[_loc8_].radius + 0.25)
  498.                {
  499.                   freezeActiveBall();
  500.                   return;
  501.                }
  502.                _loc8_++;
  503.             }
  504.          }
  505.       }
  506.       
  507.       public function fetchHighScores(param1:Object = null) : void
  508.       {
  509.          var _loc2_:Sprite = null;
  510.          var _loc3_:TextScoreTable = null;
  511.          var _loc4_:TextField = null;
  512.          var _loc5_:Object = null;
  513.          if(percentFilled >= 66.6)
  514.          {
  515.             return;
  516.          }
  517.          if(!GAMEPAUSED)
  518.          {
  519.             pause();
  520.          }
  521.          if(body)
  522.          {
  523.             if(contains(body))
  524.             {
  525.                removeChild(body);
  526.             }
  527.             body = null;
  528.          }
  529.          body = new MovieClip();
  530.          body.x = 0;
  531.          body.y = 0;
  532.          addChild(body);
  533.          fadeBody();
  534.          _loc2_ = new Sprite();
  535.          _loc2_.graphics.beginFill(0);
  536.          _loc2_.graphics.drawRect(100,150,400,300);
  537.          _loc2_.graphics.endFill();
  538.          _loc2_.graphics.beginFill(3355443);
  539.          _loc2_.graphics.drawRect(102,152,396,296);
  540.          _loc2_.graphics.endFill();
  541.          body.addChild(_loc2_);
  542.          _loc3_ = new TextScoreTable();
  543.          trace("table created...");
  544.          body.addChild(_loc3_);
  545.          _loc3_.x = 105;
  546.          _loc3_.y = 155;
  547.          _loc3_.init();
  548.          (_loc4_ = new_tf("center")).x = 235;
  549.          _loc4_.y = 420;
  550.          _loc4_.width = 150;
  551.          _loc4_.htmlText = "<font size=\'size:8px\'>(Click to Continue)</font>";
  552.          body.addChild(_loc4_);
  553.          body.addEventListener("click",dismissOverlay);
  554.          _loc5_ = getOptions();
  555.          _loc3_.reset("Fetching high scores...");
  556.          MochiAd.fetchHighScores(_loc5_,_loc3_,"gotScores");
  557.       }
  558.       
  559.       private function closeScoresNew(param1:Event) : void
  560.       {
  561.          newGameButton();
  562.       }
  563.       
  564.       private function ouch() : void
  565.       {
  566.          var _loc1_:SoundTransform = null;
  567.          flashRed();
  568.          --livesLeft;
  569.          livesText.text = "Lives: " + livesLeft;
  570.          if(livesLeft <= 0)
  571.          {
  572.             GAMEPAUSED = true;
  573.             stopMusic();
  574.             _loc1_ = new SoundTransform(0.5);
  575.             if(SOUNDENABLED)
  576.             {
  577.                alert05Sound.play(0,0,_loc1_);
  578.             }
  579.             setTimeout(sendHighScore,400);
  580.          }
  581.       }
  582.       
  583.       public function outOfBounds(param1:Event = null) : void
  584.       {
  585.          var _loc2_:SoundTransform = null;
  586.          player.removeParticle(activeBall);
  587.          if(SOUNDENABLED)
  588.          {
  589.             _loc2_ = new SoundTransform(1.5);
  590.             thudSound.play(0,0,_loc2_);
  591.          }
  592.          ouch();
  593.       }
  594.       
  595.       public function softBounceSound(param1:Event) : void
  596.       {
  597.          var _loc2_:SoundTransform = null;
  598.          if(!SOUNDENABLED)
  599.          {
  600.             return;
  601.          }
  602.          _loc2_ = new SoundTransform(0.15);
  603.          bounceSound.play(0,0,_loc2_);
  604.       }
  605.       
  606.       public function startMusic() : void
  607.       {
  608.          var _loc1_:SoundTransform = null;
  609.          if(musicChannel)
  610.          {
  611.             musicChannel.stop();
  612.          }
  613.          if(!MUSICENABLED)
  614.          {
  615.             return;
  616.          }
  617.          _loc1_ = new SoundTransform(0.25);
  618.          musicChannel = musicSound.play(0,100,_loc1_);
  619.       }
  620.       
  621.       public function showInterLevel(param1:Object = null) : void
  622.       {
  623.          var opts:Object = null;
  624.          var ev:Object = param1;
  625.          LASTAD = getTimer();
  626.          if(GAMEPAUSED)
  627.          {
  628.             pause();
  629.          }
  630.          GAMEPAUSED = true;
  631.          if(body)
  632.          {
  633.             if(contains(body))
  634.             {
  635.                removeChild(body);
  636.             }
  637.             body = null;
  638.          }
  639.          body = new MovieClip();
  640.          body.x = 0;
  641.          body.y = 0;
  642.          addChild(body);
  643.          fadeBody();
  644.          opts = getOptions();
  645.          opts.ad_started = function():void
  646.          {
  647.          };
  648.          opts.ad_finished = newGame;
  649.          MochiAd.showInterLevelAd(opts);
  650.       }
  651.       
  652.       private function drawUI() : void
  653.       {
  654.          var _loc1_:TextFormat = null;
  655.          var _loc2_:TextField = null;
  656.          var _loc3_:TextField = null;
  657.          var _loc4_:ezButton = null;
  658.          var _loc5_:ezButton = null;
  659.          var _loc6_:ezButton = null;
  660.          var _loc7_:ezButton = null;
  661.          var _loc8_:ezButton = null;
  662.          var _loc9_:ezButton = null;
  663.          _loc1_ = new TextFormat();
  664.          _loc1_.font = "Arial";
  665.          _loc1_.color = 16777215;
  666.          _loc1_.size = 18;
  667.          pauseText = new TextField();
  668.          pauseText.selectable = false;
  669.          pauseText.defaultTextFormat = _loc1_;
  670.          pauseText.text = "Game Paused";
  671.          pauseText.width = 250;
  672.          pauseText.x = 245;
  673.          pauseText.y = 300;
  674.          pauseOverlay = new Sprite();
  675.          pauseOverlay.graphics.beginFill(0,0.5);
  676.          pauseOverlay.graphics.drawRect(0,100,600,400);
  677.          pauseOverlay.graphics.endFill();
  678.          _loc1_.size = 24;
  679.          _loc2_ = new TextField();
  680.          _loc2_.selectable = false;
  681.          _loc2_.defaultTextFormat = _loc1_;
  682.          _loc2_.text = "filler: a game";
  683.          _loc2_.width = 400;
  684.          _loc2_.x = 5;
  685.          _loc2_.y = 5;
  686.          bg.addChild(_loc2_);
  687.          _loc1_.size = 16;
  688.          _loc3_ = new TextField();
  689.          _loc3_.selectable = false;
  690.          _loc3_.defaultTextFormat = _loc1_;
  691.          _loc3_.htmlText = "<a href=\'http://www.simianlogic3d.com/blog\'>by SimianLogic</a>";
  692.          _loc3_.width = 400;
  693.          _loc3_.x = 50;
  694.          _loc3_.y = 35;
  695.          bg.addChild(_loc3_);
  696.          pctText = new TextField();
  697.          pctText.defaultTextFormat = _loc1_;
  698.          pctText.text = "0% cleared";
  699.          pctText.selectable = false;
  700.          pctText.width = 400;
  701.          pctText.x = 260;
  702.          pctText.y = 75;
  703.          bg.addChild(pctText);
  704.          scoreText = new TextField();
  705.          scoreText.defaultTextFormat = _loc1_;
  706.          scoreText.text = "Score: 0";
  707.          scoreText.selectable = false;
  708.          scoreText.width = 400;
  709.          scoreText.x = 300 - scoreText.textWidth / 2;
  710.          scoreText.y = 35;
  711.          bg.addChild(scoreText);
  712.          levelText = new TextField();
  713.          levelText.defaultTextFormat = _loc1_;
  714.          levelText.text = "Level 1";
  715.          levelText.selectable = false;
  716.          levelText.width = 200;
  717.          levelText.x = 5;
  718.          levelText.y = 75;
  719.          bg.addChild(levelText);
  720.          livesText = new TextField();
  721.          livesText.defaultTextFormat = _loc1_;
  722.          livesText.text = "Lives: 22";
  723.          livesText.selectable = false;
  724.          livesText.width = 400;
  725.          livesText.x = 530;
  726.          livesText.y = 75;
  727.          bg.addChild(livesText);
  728.          ballText = new TextField();
  729.          ballText.defaultTextFormat = _loc1_;
  730.          ballText.text = "Balls: 20";
  731.          ballText.selectable = false;
  732.          ballText.width = 400;
  733.          ballText.x = 530;
  734.          ballText.y = 55;
  735.          bg.addChild(ballText);
  736.          timerText = new TextField();
  737.          timerText.defaultTextFormat = _loc1_;
  738.          timerText.text = "Time left: 900";
  739.          timerText.selectable = false;
  740.          timerText.width = 400;
  741.          timerText.x = 500 - (timerText.textWidth + 5);
  742.          timerText.y = 5;
  743.          bg.addChild(timerText);
  744.          (_loc4_ = new ezButton("Pause","pause",100,30)).x = 300;
  745.          _loc4_.y = 5;
  746.          bg.addChild(_loc4_);
  747.          _loc4_.addEventListener("button_pause",pause);
  748.          (_loc5_ = new ezButton("Menu","showMenu",100,30)).addEventListener(MouseEvent.ROLL_OVER,showMenu);
  749.          _loc5_.x = 200;
  750.          _loc5_.y = 5;
  751.          bg.addChild(_loc5_);
  752.          verticalMenu = new Sprite();
  753.          verticalMenu.addEventListener(MouseEvent.ROLL_OUT,hideMenu);
  754.          verticalMenu.x = _loc5_.x - 1;
  755.          verticalMenu.y = 0;
  756.          verticalMenu.visible = false;
  757.          verticalMenu.graphics.beginFill(0);
  758.          verticalMenu.graphics.drawRect(0,0,102,100);
  759.          verticalMenu.graphics.endFill();
  760.          (_loc6_ = new ezButton("NewGame","newGame",100,25)).x = 1;
  761.          _loc6_.y = 2;
  762.          verticalMenu.addChild(_loc6_);
  763.          _loc6_.addEventListener("button_newGame",newGameButton);
  764.          (_loc7_ = new ezButton("Instructions","help",100,25)).x = 1;
  765.          _loc7_.y = 26;
  766.          verticalMenu.addChild(_loc7_);
  767.          _loc7_.addEventListener("button_help",showInstructions);
  768.          (_loc8_ = new ezButton("SFX Off","sfx",100,25)).x = 1;
  769.          _loc8_.y = 50;
  770.          verticalMenu.addChild(_loc8_);
  771.          _loc8_.addEventListener("button_sfx",toggleSFX);
  772.          (_loc9_ = new ezButton("Music Off","music",100,25)).x = 1;
  773.          _loc9_.y = 74;
  774.          verticalMenu.addChild(_loc9_);
  775.          _loc9_.addEventListener("button_music",toggleMusic);
  776.          bg.addChild(verticalMenu);
  777.       }
  778.       
  779.       private function mouseDown(param1:Event) : void
  780.       {
  781.          var _loc2_:Array = null;
  782.          if(GAMEPAUSED)
  783.          {
  784.             return;
  785.          }
  786.          _loc2_ = player.getAll();
  787.          if(_loc2_.length > 0 && _loc2_[0] == activeBall)
  788.          {
  789.             player.removeParticle(activeBall);
  790.          }
  791.          if(mouseY > 105)
  792.          {
  793.             activeBall = new growthSprite(mouseX,mouseY,10,16777215,true);
  794.             activeBall.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
  795.             activeBall.sprite.addEventListener("outOfBoundsEvent",outOfBounds);
  796.             player.addParticle(activeBall);
  797.          }
  798.       }
  799.       
  800.       public function buttonSound(param1:Event) : void
  801.       {
  802.          var _loc2_:SoundTransform = null;
  803.          if(!SOUNDENABLED)
  804.          {
  805.             return;
  806.          }
  807.          _loc2_ = new SoundTransform(0.1);
  808.          rollOverSound.play(0,0,_loc2_);
  809.       }
  810.       
  811.       public function showInstruction2(param1:Event) : void
  812.       {
  813.          var _loc2_:Sprite = null;
  814.          var _loc3_:TextField = null;
  815.          var _loc4_:TextField = null;
  816.          var _loc5_:String = null;
  817.          var _loc6_:constantVSprite = null;
  818.          var _loc7_:Sprite = null;
  819.          var _loc8_:growthSprite = null;
  820.          var _loc9_:Sprite = null;
  821.          var _loc10_:growthSprite = null;
  822.          var _loc11_:Sprite = null;
  823.          var _loc12_:growthSprite = null;
  824.          var _loc13_:Sprite = null;
  825.          var _loc14_:growthSprite = null;
  826.          var _loc15_:Sprite = null;
  827.          var _loc16_:TextField = null;
  828.          var _loc17_:TextField = null;
  829.          var _loc18_:TextField = null;
  830.          var _loc19_:TextField = null;
  831.          var _loc20_:ezButton = null;
  832.          var _loc21_:ezButton = null;
  833.          if(!GAMEPAUSED)
  834.          {
  835.             pause();
  836.          }
  837.          if(Boolean(body) && contains(body))
  838.          {
  839.             removeChild(body);
  840.          }
  841.          body = new MovieClip();
  842.          _loc2_ = new Sprite();
  843.          _loc2_.graphics.beginFill(0);
  844.          _loc2_.graphics.drawRect(0,0,400,300);
  845.          _loc2_.graphics.endFill();
  846.          _loc2_.graphics.beginFill(3355443);
  847.          _loc2_.graphics.drawRect(2,2,396,296);
  848.          _loc2_.graphics.endFill();
  849.          _loc2_.x = 100;
  850.          _loc2_.y = 150;
  851.          _loc3_ = new_tf("title");
  852.          _loc3_.x = 70;
  853.          _loc3_.y = 30;
  854.          _loc3_.width = 275;
  855.          _loc3_.text = "Instructions";
  856.          _loc2_.addChild(_loc3_);
  857.          (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify";
  858.          _loc4_.x = 25;
  859.          _loc4_.y = 90;
  860.          _loc4_.width = 350;
  861.          _loc4_.height = 250;
  862.          _loc4_.multiline = true;
  863.          _loc4_.wordWrap = true;
  864.          _loc5_ = "Press down on the mouse to create a filler ball. It will continue to grow until...";
  865.          _loc4_.htmlText = _loc5_;
  866.          _loc2_.addChild(_loc4_);
  867.          addChild(body);
  868.          body.addChild(_loc2_);
  869.          _loc7_ = (_loc6_ = new constantVSprite(0,0)).sprite;
  870.          _loc9_ = (_loc8_ = new growthSprite(0,0,30,16777215)).sprite;
  871.          _loc2_.addChild(_loc7_);
  872.          _loc2_.addChild(_loc9_);
  873.          _loc7_.x = 320;
  874.          _loc9_.x = 80;
  875.          _loc7_.y = 175;
  876.          _loc9_.y = 175;
  877.          _loc11_ = (_loc10_ = new growthSprite(0,0,20,16777215)).sprite;
  878.          _loc13_ = (_loc12_ = new growthSprite(0,0,20,16777215)).sprite;
  879.          _loc15_ = (_loc14_ = new growthSprite(0,0,20,16777215)).sprite;
  880.          _loc2_.addChild(_loc11_);
  881.          _loc2_.addChild(_loc13_);
  882.          _loc11_.x = 180;
  883.          _loc11_.y = 205;
  884.          _loc13_.x = 220;
  885.          _loc13_.y = 205;
  886.          _loc2_.addChild(_loc15_);
  887.          _loc15_.x = 290;
  888.          _loc15_.y = 175;
  889.          (_loc16_ = new_tf("center")).x = 5;
  890.          _loc16_.y = 205;
  891.          _loc16_.width = 150;
  892.          _loc16_.text = "...you release\nthe mouse";
  893.          _loc2_.addChild(_loc16_);
  894.          (_loc17_ = new_tf("center")).x = 230;
  895.          _loc17_.y = 205;
  896.          _loc17_.width = 150;
  897.          _loc17_.text = "...you run into\na bouncy ball";
  898.          _loc2_.addChild(_loc17_);
  899.          (_loc18_ = new_tf("center")).x = 125;
  900.          _loc18_.y = 145;
  901.          _loc18_.width = 150;
  902.          _loc18_.text = "...you run into\na filler ball";
  903.          _loc2_.addChild(_loc18_);
  904.          (_loc19_ = new_tf("center")).x = 260;
  905.          _loc19_.y = 145;
  906.          _loc19_.width = 150;
  907.          _loc19_.text = "OUCH!";
  908.          _loc2_.addChild(_loc19_);
  909.          _loc2_.graphics.lineStyle(1,0,1);
  910.          _loc2_.graphics.beginFill(7798784);
  911.          _loc2_.graphics.drawRect(260,135,100,70);
  912.          _loc2_.graphics.endFill();
  913.          _loc20_ = new ezButton("Next","inst_2",80,25);
  914.          _loc21_ = new ezButton("Start","skip_instructions",80,25);
  915.          _loc2_.addChild(_loc20_);
  916.          _loc20_.x = 200;
  917.          _loc20_.y = 260;
  918.          _loc2_.addChild(_loc21_);
  919.          _loc21_.x = 115;
  920.          _loc21_.y = 260;
  921.          _loc21_.addEventListener("button_skip_instructions",dismissOverlay);
  922.          _loc20_.addEventListener("button_inst_2",showInstructions3);
  923.       }
  924.       
  925.       private function showRoundup(param1:Event = null) : void
  926.       {
  927.       }
  928.       
  929.       public function init(param1:Boolean) : void
  930.       {
  931.          var _loc2_:shadowRectParticle = null;
  932.          var _loc3_:shadowRectParticle = null;
  933.          var _loc4_:shadowRectParticle = null;
  934.          var _loc5_:shadowRectParticle = null;
  935.          MochiBot.track(this,"446d3202");
  936.          kongregate = new KongregateAPI();
  937.          addChild(kongregate);
  938.          kongregate.addEventListener(KongregateEvent.COMPLETE,kongConnected);
  939.          bg = new Sprite();
  940.          bg.graphics.beginFill(5592405);
  941.          bg.graphics.drawRect(0,0,600,500);
  942.          bg.graphics.endFill();
  943.          addChild(bg);
  944.          stage.frameRate = 45;
  945.          addEventListener(Event.ENTER_FRAME,run);
  946.          rollOverSound = new rollOverMp3();
  947.          addEventListener("sound_rollover",buttonSound);
  948.          alert05Sound = new modAlert05Mp3();
  949.          alert24Sound = new modAlert24Mp3();
  950.          bounceSound = new boopMp3();
  951.          thudSound = new thudMp3();
  952.          flingSound = new flingMp3();
  953.          APEngine.init(1 / 4);
  954.          APEngine.damping = 1;
  955.          APEngine.container = this;
  956.          world = new Group();
  957.          player = new Group();
  958.          bouncyBalls = new Group();
  959.          fillerBalls = new Group();
  960.          _loc2_ = new shadowRectParticle(595,300,10,400,0,true,1,0.25);
  961.          _loc3_ = new shadowRectParticle(300,495,600,10,0,true,1,0.25);
  962.          _loc4_ = new shadowRectParticle(300,105,600,10,0,true,1,0.25);
  963.          _loc5_ = new shadowRectParticle(5,300,10,400,0,true,1,0.25);
  964.          _loc2_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
  965.          _loc5_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
  966.          _loc3_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
  967.          _loc4_.sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
  968.          world.addParticle(_loc2_);
  969.          world.addParticle(_loc5_);
  970.          world.addParticle(_loc4_);
  971.          world.addParticle(_loc3_);
  972.          player.addCollidable(world);
  973.          bouncyBalls.addCollidable(world);
  974.          fillerBalls.addCollidable(world);
  975.          bouncyBalls.addCollidable(fillerBalls);
  976.          bouncyBalls.collideInternal = true;
  977.          fillerBalls.collideInternal = true;
  978.          APEngine.addGroup(world);
  979.          APEngine.addGroup(player);
  980.          APEngine.addGroup(bouncyBalls);
  981.          APEngine.addGroup(fillerBalls);
  982.          bg.addEventListener(MouseEvent.MOUSE_DOWN,mouseDown);
  983.          bg.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
  984.          drawUI();
  985.          musicSound = new musicMp3();
  986.          logoSprite = new kongLogo() as DisplayObject;
  987.          splashSprite = new kongSplash() as DisplayObject;
  988.          showKongSplash();
  989.       }
  990.       
  991.       public function configureOverlays() : void
  992.       {
  993.          var _loc1_:Sprite = null;
  994.          var _loc2_:TextField = null;
  995.          var _loc3_:TextField = null;
  996.          var _loc4_:int = 0;
  997.          var _loc5_:int = 0;
  998.          var _loc6_:int = 0;
  999.          var _loc7_:int = 0;
  1000.          var _loc8_:int = 0;
  1001.          var _loc9_:TextField = null;
  1002.          var _loc10_:TextField = null;
  1003.          if(Boolean(body) && contains(body))
  1004.          {
  1005.             removeChild(body);
  1006.          }
  1007.          body = new MovieClip();
  1008.          _loc1_ = new Sprite();
  1009.          _loc1_.graphics.beginFill(0);
  1010.          _loc1_.graphics.drawRect(0,0,360,300);
  1011.          _loc1_.graphics.endFill();
  1012.          _loc1_.graphics.beginFill(3355443);
  1013.          _loc1_.graphics.drawRect(2,2,356,296);
  1014.          _loc1_.graphics.endFill();
  1015.          _loc1_.x = 130;
  1016.          _loc1_.y = 150;
  1017.          _loc2_ = new_tf("title");
  1018.          _loc2_.x = 50;
  1019.          _loc2_.y = 30;
  1020.          _loc2_.width = 275;
  1021.          _loc2_.text = "Level Complete!";
  1022.          _loc1_.addChild(_loc2_);
  1023.          _loc3_ = new_tf("right");
  1024.          _loc3_.x = 10;
  1025.          _loc3_.y = 90;
  1026.          _loc3_.width = 200;
  1027.          _loc3_.height = 300;
  1028.          _loc3_.htmlText = "Completion Bonus:\n Lives Bonus:\n Time Bonus:\n Balls Left Bonus: \n\n <b>Total Bonus:";
  1029.          _loc1_.addChild(_loc3_);
  1030.          _loc4_ = Math.max(0,Math.round((percentFilled - 66.6) * (CURRENTLEVEL + 5) * 4));
  1031.          _loc5_ = livesLeft * 25;
  1032.          _loc6_ = Math.floor(timeLeft / 1000);
  1033.          _loc7_ = ballsLeft * 5;
  1034.          _loc8_ = _loc4_ + _loc5_ + _loc6_ + _loc7_;
  1035.          playerScore += _loc8_;
  1036.          if(playerScore > 40000 && Send40K)
  1037.          {
  1038.             Send40K = false;
  1039.             kongregate.stats.submit("40K Points",1);
  1040.          }
  1041.          scoreText.text = "Score: " + playerScore;
  1042.          (_loc9_ = new_tf("right")).x = 160;
  1043.          _loc9_.y = 90;
  1044.          _loc9_.width = 100;
  1045.          _loc9_.height = 300;
  1046.          _loc9_.htmlText = _loc4_ + "\n" + _loc5_ + "\n" + _loc6_ + "\n" + _loc7_ + "\n\n<b>" + _loc8_ + "</b>";
  1047.          _loc1_.addChild(_loc9_);
  1048.          addChild(body);
  1049.          body.addChild(_loc1_);
  1050.          (_loc10_ = new_tf("center")).x = 115;
  1051.          _loc10_.y = 200;
  1052.          _loc10_.width = 150;
  1053.          _loc10_.htmlText = "<font size=\'size:8px\'>(Click to Continue)</font>";
  1054.          _loc1_.addChild(_loc10_);
  1055.          createKongSprite();
  1056.          body.addChild(kongSprite);
  1057.          kongSprite.x = _loc1_.x + 10;
  1058.          kongSprite.y = _loc1_.y + 235;
  1059.          kongSprite.buttonMode = true;
  1060.          kongSprite.addEventListener("click",goToKongregate);
  1061.          _loc1_.mouseChildren = false;
  1062.          _loc1_.addEventListener("click",nextLevel);
  1063.          fadeBody();
  1064.       }
  1065.       
  1066.       public function showInstructions3(param1:Event = null) : void
  1067.       {
  1068.          var _loc2_:Sprite = null;
  1069.          var _loc3_:TextField = null;
  1070.          var _loc4_:TextField = null;
  1071.          var _loc5_:String = null;
  1072.          var _loc6_:TextField = null;
  1073.          var _loc7_:String = null;
  1074.          var _loc8_:int = 0;
  1075.          var _loc9_:ezButton = null;
  1076.          var _loc10_:ezButton = null;
  1077.          var _loc11_:growthSprite = null;
  1078.          var _loc12_:Sprite = null;
  1079.          var _loc13_:growthSprite = null;
  1080.          var _loc14_:Sprite = null;
  1081.          if(!GAMEPAUSED)
  1082.          {
  1083.             pause();
  1084.          }
  1085.          if(Boolean(body) && contains(body))
  1086.          {
  1087.             removeChild(body);
  1088.          }
  1089.          body = new MovieClip();
  1090.          _loc2_ = new Sprite();
  1091.          _loc2_.graphics.beginFill(0);
  1092.          _loc2_.graphics.drawRect(0,0,400,300);
  1093.          _loc2_.graphics.endFill();
  1094.          _loc2_.graphics.beginFill(3355443);
  1095.          _loc2_.graphics.drawRect(2,2,396,296);
  1096.          _loc2_.graphics.endFill();
  1097.          _loc2_.x = 100;
  1098.          _loc2_.y = 150;
  1099.          _loc3_ = new_tf("title");
  1100.          _loc3_.x = 70;
  1101.          _loc3_.y = 30;
  1102.          _loc3_.width = 275;
  1103.          _loc3_.text = "Instructions";
  1104.          _loc2_.addChild(_loc3_);
  1105.          (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify";
  1106.          _loc4_.x = 25;
  1107.          _loc4_.y = 90;
  1108.          _loc4_.width = 350;
  1109.          _loc4_.height = 250;
  1110.          _loc4_.multiline = true;
  1111.          _loc4_.wordWrap = true;
  1112.          _loc5_ = "You get a limited number of both lives and balls each round.";
  1113.          _loc4_.htmlText = _loc5_;
  1114.          _loc2_.addChild(_loc4_);
  1115.          (_loc6_ = new_tf("left")).defaultTextFormat.align = "justify";
  1116.          _loc6_.x = 25;
  1117.          _loc6_.y = 220;
  1118.          _loc6_.width = 350;
  1119.          _loc6_.height = 250;
  1120.          _loc6_.multiline = true;
  1121.          _loc6_.wordWrap = true;
  1122.          _loc7_ = "If you run out of balls, each new ball will cost you a life.";
  1123.          _loc6_.htmlText = _loc7_;
  1124.          _loc2_.addChild(_loc6_);
  1125.          addChild(body);
  1126.          body.addChild(_loc2_);
  1127.          _loc8_ = 0;
  1128.          while(_loc8_ < 9)
  1129.          {
  1130.             _loc12_ = (_loc11_ = new growthSprite(0,0,20,16777215)).sprite;
  1131.             _loc2_.addChild(_loc12_);
  1132.             _loc12_.x = 40 + 40 * _loc8_;
  1133.             _loc12_.y = 190;
  1134.             _loc14_ = (_loc13_ = new growthSprite(0,0,20,16777215)).sprite;
  1135.             _loc2_.addChild(_loc14_);
  1136.             _loc14_.x = 40 + 40 * _loc8_;
  1137.             _loc14_.y = 150;
  1138.             _loc8_++;
  1139.          }
  1140.          _loc9_ = new ezButton("Next","inst_2",80,25);
  1141.          _loc10_ = new ezButton("Start","skip_instructions",80,25);
  1142.          _loc2_.addChild(_loc9_);
  1143.          _loc9_.x = 200;
  1144.          _loc9_.y = 260;
  1145.          _loc2_.addChild(_loc10_);
  1146.          _loc10_.x = 115;
  1147.          _loc10_.y = 260;
  1148.          _loc10_.addEventListener("button_skip_instructions",dismissOverlay);
  1149.          _loc9_.addEventListener("button_inst_2",showInstructions4);
  1150.       }
  1151.       
  1152.       public function showInstructions4(param1:Event = null) : void
  1153.       {
  1154.          var _loc2_:Sprite = null;
  1155.          var _loc3_:TextField = null;
  1156.          var _loc4_:TextField = null;
  1157.          var _loc5_:String = null;
  1158.          var _loc6_:ezButton = null;
  1159.          if(!GAMEPAUSED)
  1160.          {
  1161.             pause();
  1162.          }
  1163.          if(Boolean(body) && contains(body))
  1164.          {
  1165.             removeChild(body);
  1166.          }
  1167.          body = new MovieClip();
  1168.          _loc2_ = new Sprite();
  1169.          _loc2_.graphics.beginFill(0);
  1170.          _loc2_.graphics.drawRect(0,0,400,300);
  1171.          _loc2_.graphics.endFill();
  1172.          _loc2_.graphics.beginFill(3355443);
  1173.          _loc2_.graphics.drawRect(2,2,396,296);
  1174.          _loc2_.graphics.endFill();
  1175.          _loc2_.x = 100;
  1176.          _loc2_.y = 150;
  1177.          _loc3_ = new_tf("title");
  1178.          _loc3_.x = 70;
  1179.          _loc3_.y = 30;
  1180.          _loc3_.width = 275;
  1181.          _loc3_.text = "Instructions";
  1182.          _loc2_.addChild(_loc3_);
  1183.          (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify";
  1184.          _loc4_.x = 25;
  1185.          _loc4_.y = 90;
  1186.          _loc4_.width = 350;
  1187.          _loc4_.height = 250;
  1188.          _loc4_.multiline = true;
  1189.          _loc4_.wordWrap = true;
  1190.          _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!";
  1191.          _loc4_.htmlText = _loc5_;
  1192.          _loc2_.addChild(_loc4_);
  1193.          addChild(body);
  1194.          body.addChild(_loc2_);
  1195.          _loc6_ = new ezButton("Start","skip_instructions",80,25);
  1196.          _loc2_.addChild(_loc6_);
  1197.          _loc6_.x = 155;
  1198.          _loc6_.y = 260;
  1199.          _loc6_.addEventListener("button_skip_instructions",dismissOverlay);
  1200.       }
  1201.       
  1202.       private function fadeHandler(param1:TimerEvent) : void
  1203.       {
  1204.          ++slideCount;
  1205.          body.alpha = slideCount / 40;
  1206.       }
  1207.       
  1208.       public function postSplash() : void
  1209.       {
  1210.          startLevel(1);
  1211.          showInstructions();
  1212.          bg.removeChild(pauseText);
  1213.       }
  1214.       
  1215.       private function toggleMusic(param1:Event = null) : void
  1216.       {
  1217.          if(MUSICENABLED)
  1218.          {
  1219.             MUSICENABLED = false;
  1220.             stopMusic();
  1221.             param1.target.label = "Music On";
  1222.          }
  1223.          else
  1224.          {
  1225.             MUSICENABLED = true;
  1226.             startMusic();
  1227.             param1.target.label = "Music Off";
  1228.          }
  1229.       }
  1230.       
  1231.       private function checkSponsorLock() : void
  1232.       {
  1233.          var _loc1_:Sprite = null;
  1234.          var _loc2_:TextField = null;
  1235.          if(GAMEPAUSED)
  1236.          {
  1237.             return;
  1238.          }
  1239.          if(getTimer() < 300000)
  1240.          {
  1241.             return;
  1242.          }
  1243.          GAMEPAUSED = true;
  1244.          if(Boolean(body) && contains(body))
  1245.          {
  1246.             removeChild(body);
  1247.          }
  1248.          body = new MovieClip();
  1249.          body.x = 0;
  1250.          body.y = 0;
  1251.          addChild(body);
  1252.          _loc1_ = new Sprite();
  1253.          _loc1_.graphics.beginFill(0,0.5);
  1254.          _loc1_.graphics.drawRect(0,0,600,500);
  1255.          _loc1_.graphics.endFill();
  1256.          body.addChild(_loc1_);
  1257.          _loc2_ = new_tf("center");
  1258.          _loc2_.text = "This game has not yet been released.  If you would like \n";
  1259.          _loc2_.appendText("to sponsor it, send an email to learnyourabcs@gmail.com.");
  1260.          _loc2_.width = 400;
  1261.          _loc2_.x = 100;
  1262.          _loc2_.y = 200;
  1263.          body.addChild(_loc2_);
  1264.          fadeBody();
  1265.       }
  1266.       
  1267.       public function showInstructions(param1:Event = null) : void
  1268.       {
  1269.          var _loc2_:Sprite = null;
  1270.          var _loc3_:TextField = null;
  1271.          var _loc4_:TextField = null;
  1272.          var _loc5_:* = null;
  1273.          var _loc6_:constantVSprite = null;
  1274.          var _loc7_:Sprite = null;
  1275.          var _loc8_:growthSprite = null;
  1276.          var _loc9_:Sprite = null;
  1277.          var _loc10_:TextField = null;
  1278.          var _loc11_:TextField = null;
  1279.          var _loc12_:ezButton = null;
  1280.          var _loc13_:ezButton = null;
  1281.          if(!GAMEPAUSED)
  1282.          {
  1283.             pause();
  1284.          }
  1285.          if(Boolean(body) && contains(body))
  1286.          {
  1287.             removeChild(body);
  1288.          }
  1289.          body = new MovieClip();
  1290.          _loc2_ = new Sprite();
  1291.          _loc2_.graphics.beginFill(0);
  1292.          _loc2_.graphics.drawRect(0,0,400,300);
  1293.          _loc2_.graphics.endFill();
  1294.          _loc2_.graphics.beginFill(3355443);
  1295.          _loc2_.graphics.drawRect(2,2,396,296);
  1296.          _loc2_.graphics.endFill();
  1297.          _loc2_.x = 100;
  1298.          _loc2_.y = 150;
  1299.          _loc3_ = new_tf("title");
  1300.          _loc3_.x = 70;
  1301.          _loc3_.y = 30;
  1302.          _loc3_.width = 275;
  1303.          _loc3_.text = "Instructions";
  1304.          _loc2_.addChild(_loc3_);
  1305.          (_loc4_ = new_tf("left")).defaultTextFormat.align = "justify";
  1306.          _loc4_.x = 25;
  1307.          _loc4_.y = 90;
  1308.          _loc4_.width = 350;
  1309.          _loc4_.height = 250;
  1310.          _loc4_.multiline = true;
  1311.          _loc4_.wordWrap = true;
  1312.          _loc5_ = (_loc5_ = "The goal of <b>filler</b> is to fill up 2/3 of the screen while ") + "avoiding the bouncing balls.";
  1313.          _loc4_.htmlText = _loc5_;
  1314.          _loc2_.addChild(_loc4_);
  1315.          addChild(body);
  1316.          body.addChild(_loc2_);
  1317.          _loc7_ = (_loc6_ = new constantVSprite(0,0)).sprite;
  1318.          _loc9_ = (_loc8_ = new growthSprite(0,0,30,16777215)).sprite;
  1319.          _loc2_.addChild(_loc7_);
  1320.          _loc2_.addChild(_loc9_);
  1321.          _loc7_.x = 290;
  1322.          _loc9_.x = 100;
  1323.          _loc7_.y = 185;
  1324.          _loc9_.y = 185;
  1325.          (_loc10_ = new_tf("center")).x = 25;
  1326.          _loc10_.y = 225;
  1327.          _loc10_.width = 150;
  1328.          _loc10_.text = "filler ball = good";
  1329.          _loc2_.addChild(_loc10_);
  1330.          (_loc11_ = new_tf("center")).x = 210;
  1331.          _loc11_.y = 225;
  1332.          _loc11_.width = 150;
  1333.          _loc11_.text = "bouncy ball = bad";
  1334.          _loc2_.addChild(_loc11_);
  1335.          _loc12_ = new ezButton("Next","inst_2",80,25);
  1336.          _loc13_ = new ezButton("Start","skip_instructions",80,25);
  1337.          _loc2_.addChild(_loc12_);
  1338.          _loc12_.x = 200;
  1339.          _loc12_.y = 260;
  1340.          _loc2_.addChild(_loc13_);
  1341.          _loc13_.x = 115;
  1342.          _loc13_.y = 260;
  1343.          _loc13_.addEventListener("button_skip_instructions",dismissOverlay);
  1344.          _loc12_.addEventListener("button_inst_2",showInstruction2);
  1345.          if(getTimer() > 30000)
  1346.          {
  1347.             fadeBody();
  1348.          }
  1349.       }
  1350.       
  1351.       public function stopMusic() : void
  1352.       {
  1353.          if(musicChannel)
  1354.          {
  1355.             musicChannel.stop();
  1356.          }
  1357.       }
  1358.       
  1359.       public function tallyPercent() : void
  1360.       {
  1361.          var _loc1_:Array = null;
  1362.          var _loc2_:Number = NaN;
  1363.          var _loc3_:int = 0;
  1364.          var _loc4_:* = null;
  1365.          var _loc5_:SoundTransform = null;
  1366.          _loc1_ = fillerBalls.getAll();
  1367.          _loc2_ = 0;
  1368.          _loc3_ = 0;
  1369.          while(_loc3_ < _loc1_.length)
  1370.          {
  1371.             _loc2_ += 3.1415 * _loc1_[_loc3_].radius * _loc1_[_loc3_].radius;
  1372.             _loc3_++;
  1373.          }
  1374.          percentFilled = _loc2_ / MAXAREA * 100;
  1375.          if((_loc4_ = Math.round(_loc2_ / MAXAREA * 1000) / 10 + "").indexOf(".") == -1)
  1376.          {
  1377.             _loc4_ += ".0";
  1378.          }
  1379.          pctText.text = _loc4_ + "% cleared";
  1380.          if(_loc2_ / MAXAREA * 100 >= 66.555)
  1381.          {
  1382.             if(CURRENTLEVEL == 3)
  1383.             {
  1384.                kongregate.stats.submit("Cleared Level 3",1);
  1385.             }
  1386.             HighestPercentFilled = Math.max(HighestPercentFilled,_loc2_ / MAXAREA * 100);
  1387.             GAMEPAUSED = true;
  1388.             configureOverlays();
  1389.             _loc5_ = new SoundTransform(0.5);
  1390.             if(SOUNDENABLED)
  1391.             {
  1392.                alert24Sound.play(0,0,_loc5_);
  1393.             }
  1394.          }
  1395.       }
  1396.       
  1397.       public function createKongSprite() : void
  1398.       {
  1399.          var _loc1_:TextFormat = null;
  1400.          var _loc2_:Sprite = null;
  1401.          var _loc3_:TextField = null;
  1402.          _loc1_ = new TextFormat();
  1403.          _loc1_.font = "Arial";
  1404.          _loc1_.color = 16777215;
  1405.          _loc1_.size = 10;
  1406.          _loc2_ = new Sprite();
  1407.          _loc2_.mouseChildren = false;
  1408.          _loc2_.graphics.beginFill(0);
  1409.          _loc2_.graphics.lineStyle(1,16777215,1);
  1410.          _loc2_.graphics.drawRect(0,15,340,40);
  1411.          _loc2_.graphics.endFill();
  1412.          _loc2_.addChild(logoSprite);
  1413.          logoSprite.x = 0;
  1414.          logoSprite.y = 0;
  1415.          _loc3_ = new_tf("left");
  1416.          _loc3_.defaultTextFormat = _loc1_;
  1417.          _loc3_.text = "Sponsored by:";
  1418.          _loc2_.addChild(_loc3_);
  1419.          _loc3_.x = 0;
  1420.          _loc3_.y = 16;
  1421.          _loc1_.size = 12;
  1422.          kongText = new_tf("left");
  1423.          kongText.width = 300;
  1424.          kongText.defaultTextFormat = _loc1_;
  1425.          kongText.text = "Play more games on Kongregate\nto chat and earn badges!";
  1426.          _loc2_.addChild(kongText);
  1427.          kongText.x = 155;
  1428.          kongText.y = 19;
  1429.          kongSprite = _loc2_;
  1430.       }
  1431.       
  1432.       public function kongConnected(param1:KongregateEvent) : void
  1433.       {
  1434.          trace("Succesfully connected to Kongregate API");
  1435.       }
  1436.       
  1437.       private function redTimerHandler(param1:TimerEvent) : void
  1438.       {
  1439.          var _loc2_:Number = NaN;
  1440.          var _loc3_:int = 0;
  1441.          var _loc4_:uint = 0;
  1442.          var _loc5_:uint = 0;
  1443.          var _loc6_:uint = 0;
  1444.          ++redCount;
  1445.          _loc2_ = redCount / 20;
  1446.          _loc3_ = _loc2_ * 85;
  1447.          bg.graphics.clear();
  1448.          _loc4_ = uint(85 << 16);
  1449.          _loc5_ = uint(_loc3_ << 8);
  1450.          _loc6_ = uint(_loc3_);
  1451.          bg.graphics.beginFill(_loc4_ + _loc5_ + _loc6_);
  1452.          bg.graphics.drawRect(0,0,600,500);
  1453.          bg.graphics.endFill();
  1454.       }
  1455.       
  1456.       public function sendHighScore(param1:Object = null) : void
  1457.       {
  1458.          var TX:int = 0;
  1459.          var scoreBG:Sprite = null;
  1460.          var table:TextScoreTable = null;
  1461.          var format:TextFormat = null;
  1462.          var scoreLabel:TextField = null;
  1463.          var nameLabel:TextField = null;
  1464.          var scoreText:TextField = null;
  1465.          var nameField:TextField = null;
  1466.          var submit:ezButton = null;
  1467.          var ng:ezButton = null;
  1468.          var doneWithScores:ezButton = null;
  1469.          var sendScore:Function = null;
  1470.          var ev:Object = param1;
  1471.          if(GAMEPAUSED)
  1472.          {
  1473.             pause();
  1474.          }
  1475.          GAMEPAUSED = true;
  1476.          stopMusic();
  1477.          kongregate.scores.submit(playerScore);
  1478.          kongregate.stats.submit("Filler Balls Created",TotalBallsMade);
  1479.          kongregate.stats.submit("Highest Level",CURRENTLEVEL);
  1480.          kongregate.stats.submit("Highest Percent",HighestPercentFilled);
  1481.          if(body)
  1482.          {
  1483.             if(contains(body))
  1484.             {
  1485.                removeChild(body);
  1486.             }
  1487.             body = null;
  1488.          }
  1489.          body = new MovieClip();
  1490.          body.x = 0;
  1491.          body.y = 0;
  1492.          addChild(body);
  1493.          TX = 125;
  1494.          scoreBG = new Sprite();
  1495.          scoreBG.graphics.beginFill(0);
  1496.          scoreBG.graphics.drawRect(TX - 5,150,360,300);
  1497.          scoreBG.graphics.endFill();
  1498.          scoreBG.graphics.beginFill(3355443);
  1499.          scoreBG.graphics.drawRect(TX - 3,152,356,296);
  1500.          scoreBG.graphics.endFill();
  1501.          body.addChild(scoreBG);
  1502.          table = new TextScoreTable();
  1503.          trace("table created...");
  1504.          body.addChild(table);
  1505.          table.x = TX;
  1506.          table.y = 155;
  1507.          table.init();
  1508.          table.title.text = " Game Over! ";
  1509.          format = new TextFormat();
  1510.          format.font = "Arial";
  1511.          format.color = 16777215;
  1512.          format.size = 16;
  1513.          scoreLabel = new TextField();
  1514.          scoreLabel.defaultTextFormat = format;
  1515.          scoreLabel.selectable = false;
  1516.          scoreLabel.text = "Your Score:";
  1517.          scoreLabel.x = TX + 55;
  1518.          scoreLabel.y = 260;
  1519.          body.addChild(scoreLabel);
  1520.          nameLabel = new TextField();
  1521.          nameLabel.defaultTextFormat = format;
  1522.          nameLabel.selectable = false;
  1523.          nameLabel.text = "Your Name:";
  1524.          nameLabel.x = TX + 55;
  1525.          nameLabel.y = 280;
  1526.          body.addChild(nameLabel);
  1527.          scoreText = new TextField();
  1528.          scoreText.defaultTextFormat = format;
  1529.          scoreText.selectable = false;
  1530.          scoreText.text = TextScoreTable.commafy(playerScore);
  1531.          scoreText.x = TX + 158;
  1532.          scoreText.y = 260;
  1533.          scoreText.width = 120;
  1534.          body.addChild(scoreText);
  1535.          nameField = new TextField();
  1536.          nameField.defaultTextFormat = format;
  1537.          nameField.text = playerName;
  1538.          nameField.x = TX + 158;
  1539.          nameField.y = 280;
  1540.          nameField.width = 120;
  1541.          nameField.height = 22;
  1542.          nameField.border = true;
  1543.          nameField.type = TextFieldType.INPUT;
  1544.          body.addChild(nameField);
  1545.          submit = new ezButton("Submit","hsSubmit",100,36);
  1546.          submit.x = TX + 176;
  1547.          submit.y = 340;
  1548.          body.addChild(submit);
  1549.          ng = new ezButton("New Game","newGame",100,36);
  1550.          ng.x = TX + 74;
  1551.          ng.y = 340;
  1552.          body.addChild(ng);
  1553.          ng.addEventListener("button_newGame",newGameButton);
  1554.          doneWithScores = new ezButton("New Game","closeScoresAndNew",100,36);
  1555.          doneWithScores.x = TX + 245;
  1556.          doneWithScores.y = 405;
  1557.          doneWithScores.visible = false;
  1558.          body.addChild(doneWithScores);
  1559.          doneWithScores.addEventListener("button_closeScoresAndNew",closeScoresNew);
  1560.          sendScore = function(param1:Event):void
  1561.          {
  1562.             var opts:Object = null;
  1563.             var hs:String = null;
  1564.             var params:Object = null;
  1565.             var event:Event = param1;
  1566.             shrinkKongSprite();
  1567.             submit.visible = false;
  1568.             ng.visible = false;
  1569.             nameField.visible = false;
  1570.             nameLabel.visible = false;
  1571.             scoreLabel.visible = false;
  1572.             scoreText.visible = false;
  1573.             doneWithScores.visible = true;
  1574.             playerName = nameField.text;
  1575.             opts = getOptions();
  1576.             hs = "/kong2";
  1577.             try
  1578.             {
  1579.                params = root.loaderInfo.parameters;
  1580.                if(params["hsname"])
  1581.                {
  1582.                   hs = String(params["hsname"]);
  1583.                }
  1584.             }
  1585.             catch(error:Error)
  1586.             {
  1587.                trace("Whoops!");
  1588.             }
  1589.             opts.id += hs;
  1590.             opts.name = playerName;
  1591.             opts.score = playerScore;
  1592.             table.reset("Sending high score...");
  1593.             MochiAd.sendHighScore(opts,table,"gotScores");
  1594.          };
  1595.          submit.addEventListener("button_hsSubmit",sendScore);
  1596.          createKongSprite();
  1597.          kongSprite.x = TX + 5;
  1598.          kongSprite.y = 385;
  1599.          kongSprite.buttonMode = true;
  1600.          kongSprite.addEventListener("click",goToKongregate);
  1601.          body.addChild(kongSprite);
  1602.       }
  1603.       
  1604.       public function new_tf(param1:String) : TextField
  1605.       {
  1606.          var _loc2_:TextField = null;
  1607.          _loc2_ = new TextField();
  1608.          _loc2_.defaultTextFormat = scoreTextFormat(param1);
  1609.          _loc2_.selectable = false;
  1610.          return _loc2_;
  1611.       }
  1612.       
  1613.       public function hardBounceSound(param1:Event) : void
  1614.       {
  1615.          var _loc2_:SoundTransform = null;
  1616.          if(!SOUNDENABLED)
  1617.          {
  1618.             return;
  1619.          }
  1620.          _loc2_ = new SoundTransform(0.75);
  1621.          bounceSound.play(0,0,_loc2_);
  1622.       }
  1623.       
  1624.       private function newGameButton(param1:Event = null) : void
  1625.       {
  1626.          hideMenu();
  1627.          if(Boolean(body) && contains(body))
  1628.          {
  1629.             removeChild(body);
  1630.          }
  1631.          if(getTimer() - LASTAD > 900000)
  1632.          {
  1633.             showInterLevel();
  1634.          }
  1635.          else
  1636.          {
  1637.             newGame();
  1638.          }
  1639.       }
  1640.       
  1641.       public function playBounceSound(param1:Event) : void
  1642.       {
  1643.          var _loc2_:SoundTransform = null;
  1644.          if(!SOUNDENABLED)
  1645.          {
  1646.             return;
  1647.          }
  1648.          _loc2_ = new SoundTransform(0.4);
  1649.          bounceSound.play(0,0,_loc2_);
  1650.       }
  1651.       
  1652.       public function newGame(param1:Event = null) : void
  1653.       {
  1654.          if(GAMEPAUSED)
  1655.          {
  1656.             pause();
  1657.          }
  1658.          startMusic();
  1659.          playerScore = 0;
  1660.          scoreText.text = "Score: 0";
  1661.          CURRENTLEVEL = 1;
  1662.          TotalBallsMade = 0;
  1663.          startLevel(1);
  1664.       }
  1665.       
  1666.       public function showKongSplash() : void
  1667.       {
  1668.          var _loc1_:Sprite = null;
  1669.          if(Boolean(body) && contains(body))
  1670.          {
  1671.             removeChild(body);
  1672.          }
  1673.          body = new MovieClip();
  1674.          body.x = 0;
  1675.          body.y = 0;
  1676.          addChild(body);
  1677.          _loc1_ = new Sprite();
  1678.          _loc1_.graphics.beginFill(0,1);
  1679.          _loc1_.graphics.drawRect(0,0,600,500);
  1680.          _loc1_.graphics.endFill();
  1681.          _loc1_.buttonMode = true;
  1682.          body.addChild(_loc1_);
  1683.          _loc1_.addChild(splashSprite);
  1684.          splashSprite.width = 600;
  1685.          splashSprite.height = 500;
  1686.          _loc1_.mouseChildren = false;
  1687.          _loc1_.addEventListener("click",goToKongregate);
  1688.          setTimeout(postSplash,3250);
  1689.       }
  1690.       
  1691.       private function scoreTextFormat(param1:String) : TextFormat
  1692.       {
  1693.          var _loc2_:TextFormat = null;
  1694.          _loc2_ = new TextFormat();
  1695.          _loc2_.font = "_sans";
  1696.          _loc2_.color = 13421772;
  1697.          _loc2_.size = 14;
  1698.          if(param1 == "left")
  1699.          {
  1700.             _loc2_.align = TextFormatAlign.LEFT;
  1701.          }
  1702.          else if(param1 == "right")
  1703.          {
  1704.             _loc2_.align = TextFormatAlign.RIGHT;
  1705.          }
  1706.          else if(param1 == "center")
  1707.          {
  1708.             _loc2_.align = TextFormatAlign.CENTER;
  1709.          }
  1710.          else
  1711.          {
  1712.             if(param1 != "title")
  1713.             {
  1714.                throw new Error("Invalid text format " + param1);
  1715.             }
  1716.             _loc2_.align = TextFormatAlign.CENTER;
  1717.             _loc2_.color = 16777215;
  1718.             _loc2_.size = 32;
  1719.          }
  1720.          return _loc2_;
  1721.       }
  1722.       
  1723.       private function fadeHandlerDone(param1:TimerEvent) : void
  1724.       {
  1725.          body.alpha = 100;
  1726.       }
  1727.       
  1728.       public function goToKongregate(param1:Event) : void
  1729.       {
  1730.          var _loc2_:URLRequest = null;
  1731.          _loc2_ = new URLRequest("http://www.kongregate.com/?gamereferral=filler");
  1732.          navigateToURL(_loc2_,"_blank");
  1733.       }
  1734.       
  1735.       private function hideMenu(param1:Event = null) : void
  1736.       {
  1737.          verticalMenu.visible = false;
  1738.       }
  1739.       
  1740.       private function pause(param1:Event = null) : void
  1741.       {
  1742.          if(GAMEPAUSED)
  1743.          {
  1744.             if(Boolean(body) && contains(body))
  1745.             {
  1746.                return;
  1747.             }
  1748.             GAMEPAUSED = false;
  1749.             LASTUPDATE = getTimer();
  1750.             if(bg.contains(pauseOverlay))
  1751.             {
  1752.                bg.removeChild(pauseOverlay);
  1753.             }
  1754.             if(bg.contains(pauseText))
  1755.             {
  1756.                bg.removeChild(pauseText);
  1757.             }
  1758.             startMusic();
  1759.          }
  1760.          else
  1761.          {
  1762.             GAMEPAUSED = true;
  1763.             bg.addChild(pauseOverlay);
  1764.             bg.addChild(pauseText);
  1765.             stopMusic();
  1766.          }
  1767.       }
  1768.    }
  1769. }
  1770.