Advertisement
curiousGaming

Wish upon a star main class

Jun 26th, 2011
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.display.*;
  4.     import flash.events.*;
  5.     import flash.text.*;
  6.     import flash.display.LoaderInfo;
  7.     import flash.display.Loader;
  8.     import flash.net.URLRequest;
  9.     import flash.system.Security;
  10.    
  11.     /**
  12.      * ...
  13.      * @author tom fraser (curiousGaming)
  14.      */
  15.     public class GITD20 extends MovieClip
  16.     {
  17.         private var playerInput : PlayerInput;
  18.         private var mxv : Number;
  19.         private var myv : Number;
  20.         private var starArray : Array;
  21.         private var miniStar : Array;
  22.         private var score : int;
  23.         private var timeLeft : int;
  24.         private var introClip : MovieClip;
  25.         private var day : int;
  26.        
  27.         private var dayScore : int;
  28.        
  29.         private var starCount : int;
  30.         private var allowedTime : int;
  31.         private var speedPower : int;
  32.         private var silverCount : int;
  33.         private var gravity : int;
  34.         private var brake : int;
  35.         private var victoryAchieved : Boolean;
  36.        
  37.         private var startButton : SimpleButton;
  38.         private var continueButton : SimpleButton;
  39.         private var dadMeeple : MovieClip;
  40.         private var meeple : MovieClip;
  41.         public var kongregate : *;
  42.        
  43.         public function GITD20() : void
  44.         {
  45.             stage.showDefaultContextMenu = false;
  46.             stage.focus = stage;
  47.             stage.stageFocusRect = false;
  48.             loadKong();
  49.         }
  50.    
  51.         public function loadKong() : void
  52.         {
  53.             // Pull the API path from the FlashVars
  54.             var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;
  55.              
  56.             // The API path. The "shadow" API will load if testing locally.
  57.             var apiPath:String = paramObj.kongregate_api_path ||
  58.               "http://www.kongregate.com/flash/API_AS3_Local.swf";
  59.              
  60.             // Allow the API access to this SWF
  61.             Security.allowDomain(apiPath);
  62.              
  63.             // Load the API
  64.             var request:URLRequest = new URLRequest(apiPath);
  65.             var loader:Loader = new Loader();
  66.             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
  67.             loader.load(request);
  68.             this.addChild(loader); 
  69.         }
  70.        
  71.         function loadComplete(event:Event):void
  72.         {
  73.             // Save Kongregate API reference
  74.             kongregate = event.target.content;
  75.          
  76.             // Connect to the back-end
  77.             kongregate.services.connect();
  78.         }
  79.        
  80.    
  81.         public function begin() : void
  82.         {
  83.             if (this.root.loaderInfo.url.indexOf("kongregate.com") != -1) //change == to != for site locking code
  84.             {
  85.                 starArray = [];
  86.                 miniStar = [];
  87.                 intro();
  88.                 playerInput = new PlayerInput(stage);
  89.                 meeple = new Meeple();
  90.                 addChild(meeple);
  91.             }
  92.             else
  93.             {
  94.                 var siteLockBox : MovieClip = new SiteLockBox();
  95.                 addChild(siteLockBox);
  96.                 siteLockBox.x = (stage.stageWidth) / 2 - (siteLockBox.width / 2);
  97.                 siteLockBox.y = (stage.stageHeight) / 2 - (siteLockBox.height / 2);
  98.             }
  99.         }
  100.        
  101.         private function intro() : void
  102.         {
  103.             SoundManager.musicForbidden = true;
  104.             introClip = new IntroClip();
  105.             addChild(introClip);
  106.             introClip.gotoAndStop(1);
  107.             introClip.addEventListener(MouseEvent.CLICK, nextPage);
  108.             stage.addEventListener(KeyboardEvent.KEY_DOWN, nextPage);
  109.         }
  110.        
  111.         private function nextPage(e : Event) : void
  112.         {
  113.             if (introClip.currentFrame == 3)
  114.             {
  115.                 introClip.removeEventListener(MouseEvent.CLICK, nextPage);
  116.                 stage.removeEventListener(KeyboardEvent.KEY_DOWN, nextPage);
  117.                 introClip.parent.removeChild(introClip);
  118.                 stage.focus = stage;
  119.                 initialiseGame();
  120.                 SoundManager.musicForbidden = false;
  121.                 SoundManager.bootMusic();
  122.             }
  123.             else
  124.             {
  125.                 introClip.gotoAndStop(introClip.currentFrame+1);
  126.             }
  127.         }
  128.        
  129.         private function initialiseGame() : void
  130.         {
  131.             score = 1;
  132.             day = 0;
  133.             scoreText.text = score.toString();
  134.             starCount = 20;
  135.             allowedTime = 20;
  136.             speedPower = 2;
  137.             silverCount = 0;
  138.             gravity = 0;
  139.             brake = 0;
  140.             victoryAchieved = false;
  141.             nextLevel();
  142.         }
  143.        
  144.         private function clearStarsAway() : void
  145.         {
  146.             for each (var st : Star in starArray)
  147.             {
  148.                 st.dispose();
  149.             }
  150.             starArray = [];
  151.         }
  152.        
  153.         private function nextLevel() : void
  154.         {
  155.             clearStarsAway();
  156.             timeLeft = allowedTime * 50; //50fps * seconds
  157.             meeple.x = 250;
  158.             meeple.y = 362;
  159.             dayScore = 0;
  160.             mxv = 0;
  161.             myv = 0;
  162.             meeple.gotoAndStop(1);
  163.             meeple.scaleX = 1.0;
  164.            
  165.             var i : int;
  166.             var s : Star;
  167.             for (i = 0; i < starCount; i++)
  168.             {
  169.                 s = new Star(stage, 1);
  170.                 s.clip.y -= (Math.random() * 525);
  171.                 starArray.push(s);
  172.             }
  173.             for (i = 0; i < silverCount; i++)
  174.             {
  175.                 s = new Star(stage, 2);
  176.                 s.clip.y -= (Math.random() * 525);
  177.                 starArray.push(s);
  178.             }
  179.             addEventListener(Event.ENTER_FRAME, eachFrame);
  180.             stage.focus = stage;
  181.         }
  182.        
  183.         private function endOfDay() : void
  184.         {
  185.             kongregate.stats.submit ("Most stars in one day", dayScore);
  186.             kongregate.stats.submit ("Total stars grabbed", dayScore);
  187.             clearMiniStars();
  188.             removeEventListener(Event.ENTER_FRAME, eachFrame);
  189.             if (score >= 1000 && !victoryAchieved)
  190.             {
  191.                 victory();
  192.             }
  193.             else
  194.             {
  195.                 showUpgrader();
  196.             }
  197.         }
  198.        
  199.         private function showUpgrader() : void
  200.         {
  201.             introClip = new UpgraderClip();
  202.             addChild(introClip);
  203.             day++;
  204.            
  205.             introClip.dayText.text = "Day " + day.toString();
  206.             introClip.startButton.addEventListener(MouseEvent.CLICK, nextDay);
  207.            
  208.             resetUpgraderText();
  209.             introClip.box1.addEventListener(MouseEvent.CLICK, buyMoreStars);
  210.             introClip.box2.addEventListener(MouseEvent.CLICK, buyMoreTime);
  211.             introClip.box3.addEventListener(MouseEvent.CLICK, buyMoreSpeed);
  212.             introClip.box4.addEventListener(MouseEvent.CLICK, buyMoreSilver);
  213.             introClip.box5.addEventListener(MouseEvent.CLICK, buyMoreGravity);
  214.             introClip.box6.addEventListener(MouseEvent.CLICK, buyBrake);
  215.         }
  216.        
  217.         private function resetUpgraderText() : void
  218.         {
  219.             scoreText.text = score.toString();
  220.             introClip.scoreText.text = score.toString();
  221.            
  222.             introClip.box1.titleText.text = "More Stars";
  223.             introClip.box1.boxPic.gotoAndStop(1);
  224.             introClip.box1.currentText.text = "Current: " + starCount;
  225.             if (starCost() == 0)
  226.             {
  227.                 introClip.box1.nextText.text = "";
  228.                 introClip.box1.costText.text = "Fully upgraded";
  229.             }
  230.             else
  231.             {
  232.                 introClip.box1.nextText.text = "Next: " + (starCount+5);
  233.                 introClip.box1.costText.text = "Cost: " + starCost() + " stars";
  234.             }
  235.            
  236.             introClip.box2.titleText.text = "Extra Time";
  237.             introClip.box2.boxPic.gotoAndStop(2);
  238.             introClip.box2.currentText.text = "Current: " + allowedTime;
  239.             if (timeCost() == 0)
  240.             {
  241.                 introClip.box2.nextText.text = "";
  242.                 introClip.box2.costText.text = "Fully upgraded";
  243.             }
  244.             else
  245.             {
  246.                 introClip.box2.nextText.text = "Next: " + (allowedTime+10);
  247.                 introClip.box2.costText.text = "Cost: " + timeCost() + " stars";
  248.             }
  249.            
  250.             introClip.box3.titleText.text = "Run Faster";
  251.             introClip.box3.boxPic.gotoAndStop(3);
  252.             introClip.box3.currentText.text = "Current: " + speedPower;
  253.             if (speedCost() == 0)
  254.             {
  255.                 introClip.box3.nextText.text = "";
  256.                 introClip.box3.costText.text = "Fully upgraded";
  257.             }
  258.             else
  259.             {
  260.                 introClip.box3.nextText.text = "Next: " + (speedPower+1);
  261.                 introClip.box3.costText.text = "Cost: " + speedCost() + " stars";
  262.             }
  263.            
  264.             introClip.box4.titleText.text = "Silver Stars";
  265.             introClip.box4.boxPic.gotoAndStop(4);
  266.             introClip.box4.currentText.text = "Current: " + silverCount;
  267.             if (silverCost() == 0)
  268.             {
  269.                 introClip.box4.nextText.text = "";
  270.                 introClip.box4.costText.text = "Fully upgraded";
  271.             }
  272.             else
  273.             {
  274.                 introClip.box4.nextText.text = "Next: " + (silverCount+1);
  275.                 introClip.box4.costText.text = "Cost: " + silverCost() + " stars";
  276.             }
  277.            
  278.             introClip.box5.titleText.text = "Star Attraction";
  279.             introClip.box5.boxPic.gotoAndStop(5);
  280.             introClip.box5.currentText.text = "Current: " + gravity;
  281.             if (gravityCost() == 0)
  282.             {
  283.                 introClip.box5.nextText.text = "";
  284.                 introClip.box5.costText.text = "Fully upgraded";
  285.             }
  286.             else
  287.             {
  288.                 introClip.box5.nextText.text = "Next: " + (gravity+1);
  289.                 introClip.box5.costText.text = "Cost: " + gravityCost() + " stars";
  290.             }
  291.            
  292.             introClip.box6.titleText.text = "Control";
  293.             introClip.box6.boxPic.gotoAndStop(6);
  294.             if (brakeCost() == 0)
  295.             {
  296.                 introClip.box6.currentText.text = "Current: Grippy";
  297.                 introClip.box6.nextText.text = "";
  298.                 introClip.box6.costText.text = "Fully upgraded";
  299.             }
  300.             else
  301.             {
  302.                 introClip.box6.currentText.text = "Current: Slippy";
  303.                 introClip.box6.nextText.text = "Next: Grippy";
  304.                 introClip.box6.costText.text = "Cost: " + brakeCost() + " stars";
  305.             }
  306.         }
  307.        
  308.         private function brakeCost() : int
  309.         {
  310.             if (brake >= 1)
  311.             {
  312.                 return 0;
  313.             }
  314.             else
  315.             {
  316.                 return 50;
  317.             }
  318.         }
  319.        
  320.         private function gravityCost() : int
  321.         {
  322.             if (gravity >= 5)
  323.             {
  324.                 return 0;
  325.             }
  326.             else
  327.             {
  328.                 return 15 + (gravity + 1) * (gravity + 1) * 5;
  329.             }
  330.         }
  331.        
  332.         private function silverCost() : int
  333.         {
  334.             if (silverCount >= 5)
  335.             {
  336.                 return 0;
  337.             }
  338.             else
  339.             {
  340.                 return (silverCount + 1) * (silverCount + 1) * 5;
  341.             }
  342.         }
  343.        
  344.         private function speedCost() : int
  345.         {
  346.             if (speedPower >= 8)
  347.             {
  348.                 return 0;
  349.             }
  350.             else
  351.             {
  352.                 return 10 * speedPower;
  353.             }
  354.         }
  355.        
  356.         private function timeCost() : int
  357.         {
  358.             if (allowedTime >= 90)
  359.             {
  360.                 return 0;
  361.             }
  362.             else
  363.             {
  364.                 return allowedTime + 30;
  365.             }
  366.         }
  367.        
  368.         private function starCost() : int
  369.         {
  370.             if (starCount >= 50)
  371.             {
  372.                 return 0;
  373.             }
  374.             else
  375.             {
  376.                 return (2*(starCount - 10));
  377.             }
  378.         }
  379.        
  380.         private function buyMoreGravity(e : Event) : void
  381.         {
  382.             if ((score >= gravityCost()) && (gravityCost() != 0))
  383.             {
  384.                 score -= gravityCost();
  385.                 gravity += 1;
  386.                 resetUpgraderText();
  387.             }
  388.         }
  389.        
  390.         private function buyMoreStars(e : Event) : void
  391.         {
  392.             if ((score >= starCost()) && (starCost() != 0))
  393.             {
  394.                 score -= starCost();
  395.                 starCount += 5;
  396.                 resetUpgraderText();
  397.             }
  398.         }
  399.        
  400.         private function buyMoreTime(e : Event) : void
  401.         {
  402.             if ((score >= timeCost()) && (timeCost() != 0))
  403.             {
  404.                 score -= timeCost();
  405.                 allowedTime += 10;
  406.                 resetUpgraderText();
  407.             }
  408.         }
  409.        
  410.         private function buyMoreSpeed(e : Event) : void
  411.         {
  412.             if ((score >= speedCost()) && (speedCost() != 0))
  413.             {
  414.                 score -= speedCost();
  415.                 speedPower += 1;
  416.                 resetUpgraderText();
  417.             }
  418.         }
  419.        
  420.         private function buyMoreSilver(e : Event) : void
  421.         {
  422.             if ((score >= silverCost()) && (silverCost() != 0))
  423.             {
  424.                 score -= silverCost();
  425.                 silverCount += 1;
  426.                 resetUpgraderText();
  427.             }
  428.         }
  429.        
  430.         private function buyBrake(e : Event) : void
  431.         {
  432.             if ((score >= brakeCost()) && (brakeCost() != 0))
  433.             {
  434.                 score -= brakeCost();
  435.                 brake += 1;
  436.                 resetUpgraderText();
  437.             }
  438.         }
  439.        
  440.         private function nextDay(e : Event) : void
  441.         {
  442.             introClip.startButton.removeEventListener(MouseEvent.CLICK, nextDay);
  443.             introClip.box1.removeEventListener(MouseEvent.CLICK, buyMoreStars);
  444.             introClip.box2.removeEventListener(MouseEvent.CLICK, buyMoreTime);
  445.             introClip.box3.removeEventListener(MouseEvent.CLICK, buyMoreSpeed);
  446.             introClip.box4.removeEventListener(MouseEvent.CLICK, buyMoreSilver);
  447.             introClip.box5.removeEventListener(MouseEvent.CLICK, buyMoreGravity);
  448.             introClip.box6.removeEventListener(MouseEvent.CLICK, buyBrake);
  449.             removeChild(introClip);
  450.             nextLevel();
  451.         }
  452.        
  453.         private function testCollision(s : Star) : void
  454.         {
  455.             if (s.clip.y > 250)
  456.             {
  457.                 var dx : int = meeple.x - s.clip.x;
  458.                 var dy : int = meeple.y - s.clip.y;
  459.                 var dist : int = (dx * dx) + (dy * dy);
  460.                 if (dist < 400)
  461.                 {
  462.                     starBurst(s.clip);
  463.                     s.clip.y = 600;
  464.                     score++;
  465.                     dayScore++;
  466.                    
  467.                     if (s.clip.currentFrame == 2)
  468.                     {
  469.                         score += 4;
  470.                         dayScore += 4;
  471.                         SoundManager.addSound(gotStar);
  472.                     }
  473.                     else
  474.                     {
  475.                         SoundManager.addSound(gotGold);
  476.                     }
  477.                     scoreText.text = score.toString();
  478.                 }
  479.                 else if (dist < (2500 * gravity))
  480.                 {
  481.                     pullStar(s, dist/1000);
  482.                 }
  483.             }
  484.         }
  485.        
  486.         private function pullStar(s : Star, dist : Number) : void
  487.         {
  488.             if (meeple.x < s.clip.x)
  489.             {
  490.                 s.clip.x -= gravity / dist;
  491.                 if (meeple.x > s.clip.x)
  492.                 {
  493.                     s.clip.x = meeple.x;
  494.                 }
  495.             }
  496.             else if (meeple.x > s.clip.x)
  497.             {
  498.                 s.clip.x += gravity / dist;
  499.                 if (meeple.x < s.clip.x)
  500.                 {
  501.                     s.clip.x = meeple.x;
  502.                 }
  503.             }
  504.              
  505.         }
  506.        
  507.         private function eachFrame(e : Event) : void
  508.         {
  509.             SoundManager.eachFrame();
  510.             moveMiniStars();
  511.             for each (var s : Star in starArray)
  512.             {
  513.                 s.eachFrame(timeLeft);
  514.                 testCollision(s);
  515.             }
  516.             if (playerInput.leftKey())
  517.             {
  518.                 if ((brake > 0) && (mxv > 0))
  519.                 {
  520.                     mxv = 0;
  521.                 }
  522.                 meeple.scaleX = -1.0;
  523.                 mxv -= speedPower / 10;
  524.             }
  525.             if (playerInput.rightKey())
  526.             {
  527.                 if ((brake > 0) && (mxv < 0))
  528.                 {
  529.                     mxv = 0;
  530.                 }
  531.                 meeple.scaleX = 1.0;
  532.                 mxv += speedPower / 10;
  533.             }
  534.             if (playerInput.upKey() && (meeple.y >= 362))
  535.             {
  536.                 myv = -9;
  537.                 //SoundManager.addSound(jump);
  538.             }
  539.             if (!playerInput.rightKey() && !playerInput.leftKey() && brake > 0)
  540.             {
  541.                 mxv *= 0.92; //extra friction
  542.             }
  543.             meeple.x += mxv;
  544.             meeple.y += myv;
  545.             if (meeple.y > 362)
  546.             {
  547.                 meeple.y = 362;
  548.                 myv = 0;
  549.             }
  550.             mxv *= 0.95; //friction
  551.             myv += 0.8;
  552.             if (meeple.x > 495)
  553.             {
  554.                 meeple.x = 495;
  555.                 mxv = 0;
  556.             }
  557.             if (meeple.x < 5)
  558.             {
  559.                 meeple.x = 5;
  560.                 mxv = 0;
  561.             }
  562.             var desiredFrame : int = (meeple.currentFrame + Math.round(Math.abs(mxv))) % 32;
  563.             meeple.gotoAndStop(desiredFrame);
  564.            
  565.             updateTime();
  566.             if (allGone())
  567.             {
  568.                 endOfDay();
  569.             }
  570.         }
  571.        
  572.         private function allGone() : Boolean
  573.         {
  574.             var starsInPlay : int = 0;
  575.             for each (var s : Star in starArray)
  576.             {
  577.                 if (s.clip.y < 600)
  578.                 {
  579.                     starsInPlay++;
  580.                 }
  581.             }
  582.             return (starsInPlay == 0);
  583.         }
  584.        
  585.         private function updateTime() : void
  586.         {
  587.             timeLeft--;
  588.             if (timeLeft < 0)
  589.             {
  590.                 timeLeft = 0;
  591.             }
  592.             var minutesLeft : int = Math.floor(timeLeft / 3000);
  593.             var secondsLeft : int = Math.floor(timeLeft / 50) - (minutesLeft * 60);
  594.             var secondsText : String = secondsLeft.toString();
  595.             if (secondsLeft < 10)
  596.             {
  597.                 secondsText = "0" + secondsText;
  598.             }
  599.             timeText.text = minutesLeft.toString() + ":" + secondsText;
  600.         }
  601.        
  602.         private function victory() : void
  603.         {
  604.             SoundManager.musicForbidden = true;
  605.             SoundManager.stopMusic();
  606.             timeLeft = 50;
  607.             kongregate.stats.submit ("Fastest Win", (day+1));
  608.             victoryAchieved = true;
  609.             introClip = new ExitClip();
  610.             addChild(introClip);
  611.             introClip.gotoAndStop(1);
  612.             introClip.addEventListener(MouseEvent.CLICK, nextExitPage);
  613.             stage.addEventListener(KeyboardEvent.KEY_DOWN, nextExitPage);
  614.             startRunners();
  615.         }
  616.        
  617.         private function nextExitPage(e : Event) : void
  618.         {
  619.             if (timeLeft < 0)
  620.             {
  621.                 introClip.gotoAndStop(introClip.currentFrame+1);
  622.                 timeLeft = 50;
  623.                 if (introClip.currentFrame == 3)
  624.                 {
  625.                     introClip.removeEventListener(MouseEvent.CLICK, nextExitPage);
  626.                     stage.removeEventListener(KeyboardEvent.KEY_DOWN, nextExitPage);
  627.                    
  628.                     startButton = new RestartButton();
  629.                     introClip.addChild(startButton);
  630.                     startButton.x = 90;
  631.                     startButton.y = 360;
  632.                     startButton.addEventListener(MouseEvent.CLICK, reboot);
  633.                    
  634.                     continueButton = new ContinueButton();
  635.                     introClip.addChild(continueButton);
  636.                     continueButton.x = 410;
  637.                     continueButton.y = 360;
  638.                     continueButton.addEventListener(MouseEvent.CLICK, continueGame);
  639.                 }
  640.             }
  641.         }
  642.        
  643.         private function continueGame(e : Event) : void
  644.         {
  645.             clearUp();
  646.             showUpgrader();
  647.         }
  648.        
  649.         private function reboot(e : Event) : void
  650.         {
  651.             clearUp();
  652.             initialiseGame();
  653.         }
  654.        
  655.         private function clearUp() : void
  656.         {
  657.             SoundManager.musicForbidden = false;
  658.             SoundManager.bootMusic();
  659.             startButton.removeEventListener(MouseEvent.CLICK, reboot);
  660.             continueButton.removeEventListener(MouseEvent.CLICK, continueGame);
  661.             introClip.removeChild(continueButton);
  662.             introClip.removeChild(startButton);
  663.             removeChild(dadMeeple);
  664.             removeChild(introClip);
  665.             removeEventListener(Event.ENTER_FRAME, zombieRun);
  666.         }
  667.        
  668.         private function startRunners() : void
  669.         {
  670.             SoundManager.addSound(zombie);
  671.             dadMeeple = new MeepleDad();
  672.             dadMeeple.scaleX = 1.4;
  673.             dadMeeple.scaleY = 1.4;
  674.             dadMeeple.y = 240;
  675.             dadMeeple.gotoAndStop(1);
  676.             meeple.y = 240;
  677.             meeple.x = -250;
  678.             meeple.scaleX = 1.0;
  679.             mxv = 5.0;
  680.             addChild(dadMeeple);
  681.             addChild(meeple);
  682.             addEventListener(Event.ENTER_FRAME, zombieRun);
  683.         }
  684.        
  685.         private function zombieRun(e : Event) : void
  686.         {
  687.             SoundManager.eachFrame();
  688.             moveMiniStars();
  689.             timeLeft--;
  690.             meeple.x += mxv;
  691.             dadMeeple.x = meeple.x - (mxv * 15);
  692.             meeple.gotoAndStop((meeple.currentFrame + 7)%32);
  693.             dadMeeple.gotoAndStop((dadMeeple.currentFrame + 5)%32);
  694.            
  695.             if (meeple.x > 600)
  696.             {
  697.                 mxv = -5.0;
  698.                 dadMeeple.scaleX = -1.4;
  699.                 meeple.scaleX = -1;
  700.             }
  701.             if (meeple.x < -100)
  702.             {
  703.                 mxv = 5.0;
  704.                 dadMeeple.scaleX = 1.4;
  705.                 meeple.scaleX = 1;
  706.             }
  707.         }
  708.        
  709.         private function starBurst(dadClip : MovieClip) : void
  710.         {
  711.             for (var i : int = 0; i < 20; i++)
  712.             {
  713.                 var m : MiniStar = new MiniStar(stage, dadClip);
  714.                 miniStar.push(m);
  715.             }
  716.         }
  717.        
  718.         private function moveMiniStars() : void
  719.         {
  720.             for each (var m : MiniStar in miniStar)
  721.             {
  722.                 m.eachFrame();
  723.             }
  724.             for (var i : int = miniStar.length-1; i >= 0; i--)
  725.             {
  726.                 if (miniStar[i].fadeCount >= 40)
  727.                 {
  728.                     miniStar[i].dispose();
  729.                     miniStar.splice(i, 1);
  730.                 }
  731.             }
  732.         }
  733.        
  734.         private function clearMiniStars() : void
  735.         {
  736.             for (var i : int = miniStar.length-1; i >= 0; i--)
  737.             {
  738.                 miniStar[i].dispose();
  739.                 miniStar.splice(i, 1);
  740.             }
  741.             miniStar = [];
  742.         }
  743.     } //end class
  744. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement