home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / global_r.swf / scripts / __Packages / Summary.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  5.5 KB  |  192 lines

  1. class Summary extends MovieClip
  2. {
  3.    var onEnterFrame;
  4.    var sURL;
  5.    var mcDescription;
  6.    var oSpaceLst;
  7.    var mcStatusBar;
  8.    static var instance;
  9.    function Summary()
  10.    {
  11.       super();
  12.       Summary.instance = this;
  13.       this.onEnterFrame = this.init;
  14.    }
  15.    function init(Void)
  16.    {
  17.       this.onEnterFrame = null;
  18.       this.sURL = Application.sBasePath + "SaveScore.php";
  19.       if(Game.getInstance().sMissionType == "hostages")
  20.       {
  21.          this.setHostAlpha(100);
  22.       }
  23.       else
  24.       {
  25.          this.setHostAlpha(20);
  26.       }
  27.       this.mcDescription.mcTexts.gotoAndStop(1);
  28.       this.mcDescription.btnPlay.onRelease = mx.utils.Delegate.create(this,this.onReleasePlayFirst);
  29.       this.oSpaceLst = new Object();
  30.       this.oSpaceLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressSpaceFirst);
  31.       Key.addListener(this.oSpaceLst);
  32.       this.setBonusGauge(Game.getInstance().bonus);
  33.    }
  34.    static function getInstance(Void)
  35.    {
  36.       return Summary.instance;
  37.    }
  38.    function startGame(Void)
  39.    {
  40.       Game.getInstance().startGame();
  41.    }
  42.    function onReleasePlayFirst(Void)
  43.    {
  44.       Key.removeListener(this.oSpaceLst);
  45.       Sounds.stopAllSounds();
  46.       this.gotoAndPlay("firstOut");
  47.    }
  48.    function setFuelGauge(amount)
  49.    {
  50.       this.mcStatusBar.mcFuelGauge.gotoAndStop(101 - amount);
  51.    }
  52.    function setChafsGauge(amount)
  53.    {
  54.       this.mcStatusBar.chaffs = amount;
  55.    }
  56.    function setLivesGauge(amount)
  57.    {
  58.       this.mcStatusBar.lives = amount;
  59.    }
  60.    function setPointsGauge(amount)
  61.    {
  62.       this.mcStatusBar.points = amount;
  63.    }
  64.    function setOnBoardGauge(amount, maxAmount)
  65.    {
  66.       this.mcStatusBar.onBoard = amount + "/" + maxAmount;
  67.    }
  68.    function setBonusGauge(amount)
  69.    {
  70.       this.mcStatusBar.bonus = amount;
  71.    }
  72.    function showMission(Void)
  73.    {
  74.       this.mcDescription.mcTexts.gotoAndStop(Game.level + 2);
  75.       this.mcDescription.btnPlay.onRelease = mx.utils.Delegate.create(this,this.onReleasePlay);
  76.       this.oSpaceLst = new Object();
  77.       this.oSpaceLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressSpace);
  78.       Key.addListener(this.oSpaceLst);
  79.       this.gotoAndPlay("panelIn");
  80.    }
  81.    function showGameOver(bSuccess)
  82.    {
  83.       ┬º┬ºpush(this.gotoAndPlay("panelIn"));
  84.       if(bSuccess)
  85.       {
  86.          this.mcDescription.gotoAndStop("win");
  87.          this.mcDescription.btnEnter.onRelease = mx.utils.Delegate.create(this,this.onReleaseSend);
  88.          this.oSpaceLst = new Object();
  89.          this.oSpaceLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressEnterWin);
  90.          Key.addListener(this.oSpaceLst);
  91.          Selection.setFocus(this.mcDescription.tfName);
  92.       }
  93.       else
  94.       {
  95.          this.mcDescription.gotoAndStop("lose");
  96.          this.mcDescription.btnPlay.onRelease = mx.utils.Delegate.create(this,this.onReleasePlayAgain);
  97.          this.mcDescription.btnFriend.onRelease = mx.utils.Delegate.create(this,this.onReleaseFriend);
  98.          this.oSpaceLst = new Object();
  99.          this.oSpaceLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressSpaceLose);
  100.          Key.addListener(this.oSpaceLst);
  101.       }
  102.    }
  103.    function onReleasePlay(Void)
  104.    {
  105.       Key.removeListener(this.oSpaceLst);
  106.       Game.getInstance().setNextLevel();
  107.       Sounds.stopAllSounds();
  108.       this.gotoAndPlay("panelOut");
  109.    }
  110.    function onReleasePlayAgain(Void)
  111.    {
  112.       Key.removeListener(this.oSpaceLst);
  113.       _root.gotoAndPlay("gameOut");
  114.    }
  115.    function onReleaseSend(Void)
  116.    {
  117.       Key.removeListener(this.oSpaceLst);
  118.       var _loc3_ = this.mcDescription;
  119.       if(_loc3_.tfName.length > 0)
  120.       {
  121.          _loc3_.mcBlockade.gotoAndStop("show");
  122.          var _loc2_ = new LoadVars();
  123.          _loc2_.NAME = _loc3_.tfName.text;
  124.          _loc2_.SCORE = Game.getInstance().getPoints();
  125.          _loc2_.onLoad = mx.utils.Delegate.create(this,this.onSendScore);
  126.          _loc2_.sendAndLoad(this.sURL,_loc2_,"POST");
  127.       }
  128.       else
  129.       {
  130.          _loc3_.mcName.gotoAndPlay("error");
  131.          Selection.setFocus(_loc3_.tfName);
  132.          this.oSpaceLst = new Object();
  133.          this.oSpaceLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressEnterWin);
  134.          Key.addListener(this.oSpaceLst);
  135.       }
  136.    }
  137.    function onSendScore(bSuccess)
  138.    {
  139.       if(bSuccess)
  140.       {
  141.          this.mcDescription.mcBlockade.gotoAndStop("hide");
  142.          _root.gotoAndPlay("gameOut");
  143.          _root.mcInterface.gotoAndStop("high");
  144.       }
  145.       else
  146.       {
  147.          this.mcDescription.mcBlockade.gotoAndPlay("error");
  148.          this.oSpaceLst = new Object();
  149.          this.oSpaceLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressEnterWin);
  150.          Key.addListener(this.oSpaceLst);
  151.       }
  152.    }
  153.    function onPressSpaceFirst(Void)
  154.    {
  155.       if(Key.isDown(32))
  156.       {
  157.          this.onReleasePlayFirst();
  158.       }
  159.    }
  160.    function onPressSpace(Void)
  161.    {
  162.       if(Key.isDown(32))
  163.       {
  164.          this.onReleasePlay();
  165.       }
  166.    }
  167.    function onPressSpaceLose(Void)
  168.    {
  169.       if(Key.isDown(32))
  170.       {
  171.          this.onReleasePlayAgain();
  172.       }
  173.    }
  174.    function onPressEnterWin(Void)
  175.    {
  176.       if(Key.isDown(13))
  177.       {
  178.          this.onReleaseSend();
  179.       }
  180.    }
  181.    function setHostAlpha(value)
  182.    {
  183.       this.mcStatusBar.tfHostages._alpha = value;
  184.    }
  185.    function onReleaseFriend(Void)
  186.    {
  187.       Key.removeListener(this.oSpaceLst);
  188.       _root.gotoAndPlay("gameOut");
  189.       _root.mcInterface.gotoAndStop("send");
  190.    }
  191. }
  192.