Zeether

Revised GameOverScreen code

Feb 16th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Game Over screen class
  2. package
  3. {
  4.     import flash.display.MovieClip;
  5.     import flash.display.SimpleButton;
  6.     import flash.events.MouseEvent;
  7.     import flash.text.TextField;
  8.     import flash.ui.Mouse;
  9.     import NavigationEvent;
  10.    
  11.    
  12.     public class GameOverScreen extends MovieClip
  13.     {
  14.         public function GameOverScreen()
  15.         {
  16.             Mouse.show(); // show mouse cursor
  17.             restartButton.addEventListener( MouseEvent.CLICK, onClickRestart ); // add click listener to button
  18.             menuButton.addEventListener( MouseEvent.CLICK, onClickMenu); // add menu button listener
  19.         }
  20.        
  21.         public function onClickRestart(mouseEvent:MouseEvent):void // restarts the game when the restart button is clicked!
  22.         {
  23.             dispatchEvent(new NavigationEvent(NavigationEvent.RESTART));
  24.         }
  25.        
  26.         public function setFinalScore(scoreValue:Number):void // sets the final score display
  27.         {
  28.             finalScore.text = scoreValue.toString();
  29.         }
  30.        
  31.         public function onClickMenu(navigationEvent:NavigationEvent):void // brings you back to the menu!
  32.         {
  33.             dispatchEvent(new NavigationEvent(NavigationEvent.MENUSCREEN));
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment