home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / ScrollingPanel.as < prev    next >
Encoding:
Text File  |  2013-04-24  |  9.4 KB  |  257 lines

  1. class ScrollingPanel extends State
  2. {
  3.    var nInstructionsPage;
  4.    var nKeyPosition;
  5.    var sLastState;
  6.    var sState;
  7.    var mcRef;
  8.    static var sSTATE_TITLE = "TitleCard";
  9.    static var sSTATE_TITLE_TO_HOWTOPLAY = "TitleToHowToPlay";
  10.    static var sSTATE_HOWTOPLAY = "HowToPlay";
  11.    static var sSTATE_HOWTOPLAY_TO_TITLE = "HowToPlayToTitle";
  12.    static var sSTATE_HIGHSCORES = "HighScores";
  13.    static var sSTATE_HIGHSCORES_TO_TITLE = "HighScoresToTitle";
  14.    static var sSTATE_TITLE_TO_HIGHSCORES = "TitleToHighScores";
  15.    function ScrollingPanel(_mcRef)
  16.    {
  17.       super(_mcRef);
  18.       this.setState(ScrollingPanel.sSTATE_TITLE);
  19.       this.nInstructionsPage = 1;
  20.       this.nKeyPosition = 1;
  21.    }
  22.    function setState(_sState)
  23.    {
  24.       this.sLastState = this.sState;
  25.       super.setState(_sState);
  26.       this.initState(_sState);
  27.    }
  28.    function TitleToHowToPlay()
  29.    {
  30.       if(this.stateFinished())
  31.       {
  32.          var _loc2_ = this.mcRef.mcState.mcPanel.mcPage.mcKeys._currentframe;
  33.          this.setState(ScrollingPanel.sSTATE_HOWTOPLAY);
  34.          this.mcRef.mcState.mcPanel.mcPage.mcKeys.gotoAndPlay(_loc2_);
  35.       }
  36.    }
  37.    function HowToPlayToTitle()
  38.    {
  39.       if(this.stateFinished())
  40.       {
  41.          this.nKeyPosition = this.mcRef.mcState.mcPanel.mcPage.mcKeys._currentframe;
  42.          this.setState(ScrollingPanel.sSTATE_TITLE);
  43.       }
  44.    }
  45.    function TitleToHighScores()
  46.    {
  47.       if(this.stateFinished())
  48.       {
  49.          this.changeStateKeepingInfo(ScrollingPanel.sSTATE_HIGHSCORES);
  50.       }
  51.    }
  52.    function HighScoresToTitle()
  53.    {
  54.       if(this.stateFinished())
  55.       {
  56.          this.setState(ScrollingPanel.sSTATE_TITLE);
  57.       }
  58.    }
  59.    function TitleCard()
  60.    {
  61.    }
  62.    function HighScores()
  63.    {
  64.    }
  65.    function Instructions()
  66.    {
  67.    }
  68.    function moveTitleToIns()
  69.    {
  70.       this.setState(ScrollingPanel.sSTATE_TITLE_TO_HOWTOPLAY);
  71.       this.mcRef.mcState.mcPanel.mcPage.mcKeys.gotoAndPlay(this.nKeyPosition);
  72.       this.initPage();
  73.    }
  74.    function moveTitleToHighScores()
  75.    {
  76.       Main.getRef().setMustSendScore(false);
  77.       this.setState(ScrollingPanel.sSTATE_TITLE_TO_HIGHSCORES);
  78.       Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcPanel.mcSubmit);
  79.       this.checkToSubmitHighScore();
  80.       this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  81.       this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  82.    }
  83.    function desactivateButton(_mcButton)
  84.    {
  85.       delete _mcButton.button.onRollOver;
  86.       _mcButton.button.onRollOver = undefined;
  87.       delete _mcButton.button.onRelease;
  88.       _mcButton.button.onRelease = undefined;
  89.       _mcButton.gotoAndStop(2);
  90.    }
  91.    function activateButton(_mcButton, _onRelease)
  92.    {
  93.       _mcButton.gotoAndStop(1);
  94.       _mcButton.button.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  95.       _mcButton.button.onRelease = Delegate.create(this,_onRelease);
  96.    }
  97.    function nextPage()
  98.    {
  99.       Controller.getRef().playClickSound();
  100.       this.nInstructionsPage = this.nInstructionsPage + 1;
  101.       this.initPage();
  102.    }
  103.    function previousPage()
  104.    {
  105.       Controller.getRef().playClickSound();
  106.       this.nInstructionsPage = this.nInstructionsPage - 1;
  107.       this.initPage();
  108.    }
  109.    function initPage()
  110.    {
  111.       if(this.nInstructionsPage == 1)
  112.       {
  113.          this.desactivateButton(this.mcRef.mcState.mcPanel.mcBack);
  114.          this.activateButton(this.mcRef.mcState.mcPanel.mcNext,this.nextPage);
  115.       }
  116.       else if(this.nInstructionsPage == 2)
  117.       {
  118.          this.activateButton(this.mcRef.mcState.mcPanel.mcBack,this.previousPage);
  119.          this.activateButton(this.mcRef.mcState.mcPanel.mcNext,this.nextPage);
  120.       }
  121.       else if(this.nInstructionsPage == 3)
  122.       {
  123.          this.activateButton(this.mcRef.mcState.mcPanel.mcBack,this.previousPage);
  124.          this.desactivateButton(this.mcRef.mcState.mcPanel.mcNext);
  125.       }
  126.       this.mcRef.mcState.mcPanel.mcPage.gotoAndStop(this.nInstructionsPage);
  127.    }
  128.    function checkToSubmitHighScore()
  129.    {
  130.       if(_global.gProxyObj.getIsLoggedIn())
  131.       {
  132.          this.mcRef.mcState.mcPanel.mcSubmit._visible = true;
  133.       }
  134.       else
  135.       {
  136.          this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  137.       }
  138.       if(Main.getRef().MustSendScore)
  139.       {
  140.          this.clickSubmitButton();
  141.       }
  142.       else
  143.       {
  144.          _global.HS.getScores();
  145.       }
  146.    }
  147.    function initState(_sState)
  148.    {
  149.       switch(_sState)
  150.       {
  151.          case ScrollingPanel.sSTATE_TITLE:
  152.             _global.HS.initHiScores();
  153.             this.mcRef.mcState.mcPanel.btnPlay2.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  154.             this.mcRef.mcState.mcPanel.btnPlay2.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickPlayButton);
  155.             this.mcRef.mcState.mcPanel.btnHighScores.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  156.             this.mcRef.mcState.mcPanel.btnHighScores.onRelease = Delegate.create(this,this.clickTitleToHSButton);
  157.             this.mcRef.mcState.mcPanel.btnHowToPlay.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  158.             this.mcRef.mcState.mcPanel.btnHowToPlay.onRelease = Delegate.create(this,this.clickTitleToInsButton);
  159.             this.mcRef.mcState.mcPanel.btnCheat.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  160.             this.mcRef.mcState.mcPanel.btnCheat.onRelease = Delegate.create(this,this.clickEnterCodeButton);
  161.             break;
  162.          case ScrollingPanel.sSTATE_HOWTOPLAY:
  163.             this.mcRef.mcState.mcPanel.btnPlay1.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  164.             this.mcRef.mcState.mcPanel.btnPlay1.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickPlayButton);
  165.             this.initPage();
  166.             break;
  167.          case ScrollingPanel.sSTATE_HIGHSCORES:
  168.             if(this.sLastState == ScrollingPanel.sSTATE_TITLE_TO_HIGHSCORES)
  169.             {
  170.                this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  171.             }
  172.             else
  173.             {
  174.                Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcPanel.mcSubmit);
  175.                this.checkToSubmitHighScore();
  176.             }
  177.             if(this.mcRef.mcState.mcPanel.mcSubmit._visible)
  178.             {
  179.                this.mcRef.mcState.mcPanel.mcSubmit.btnSubmit.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  180.                this.mcRef.mcState.mcPanel.mcSubmit.btnSubmit.onRelease = Delegate.create(this,this.clickSubmitButton);
  181.                this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(1);
  182.             }
  183.             else
  184.             {
  185.                this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  186.             }
  187.             this.mcRef.mcState.mcPanel.mcMain.btnHSToTitle.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  188.             this.mcRef.mcState.mcPanel.mcMain.btnHSToTitle.onRelease = Delegate.create(this,this.clickHSToTitleButton);
  189.       }
  190.    }
  191.    function clickTitleToInsButton()
  192.    {
  193.       Controller.getRef().playClickSound();
  194.       this.moveTitleToIns();
  195.    }
  196.    function clickTitleToHSButton()
  197.    {
  198.       Controller.getRef().playClickSound();
  199.       this.moveTitleToHighScores();
  200.    }
  201.    function clickHSToTitleButton()
  202.    {
  203.       Controller.getRef().playClickSound();
  204.       this.changeStateKeepingInfo(ScrollingPanel.sSTATE_HIGHSCORES_TO_TITLE);
  205.    }
  206.    function clickInsToTitleButton()
  207.    {
  208.       Controller.getRef().playClickSound();
  209.       var _loc2_ = this.mcRef.mcState.mcPanel.mcPage.mcKeys._currentframe;
  210.       this.setState(ScrollingPanel.sSTATE_HOWTOPLAY_TO_TITLE);
  211.       this.mcRef.mcState.mcPanel.mcPage.mcKeys.gotoAndPlay(_loc2_);
  212.       this.initPage();
  213.    }
  214.    function clickEnterCodeButton()
  215.    {
  216.       Controller.getRef().playClickSound();
  217.       Controller.getRef().getCheatPop().doShow();
  218.    }
  219.    function clickSubmitButton()
  220.    {
  221.       _global.HS.submitScore(CTRLGame.getRef().Score);
  222.       this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  223.       if(this.mcRef.mcState.mcPanel.mcSubmit._visible)
  224.       {
  225.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(1);
  226.       }
  227.       else
  228.       {
  229.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  230.       }
  231.    }
  232.    function changeStateKeepingInfo(_sNextState)
  233.    {
  234.       var _loc3_ = this.mcRef.mcState.mcPanel.mcSubmit._visible;
  235.       var _loc4_ = this.mcRef.mcState.mcPanel.txt_highScoreNumber.text;
  236.       var _loc5_ = this.mcRef.mcState.mcPanel.txt_highScoreName.text;
  237.       var _loc6_ = this.mcRef.mcState.mcPanel.txt_highScoreScore.text;
  238.       var _loc7_ = this.mcRef.mcState.mcPanel.txt_highScoreScore.scroll;
  239.       this.setState(_sNextState);
  240.       this.mcRef.mcState.mcPanel.mcSubmit._visible = _loc3_;
  241.       if(this.mcRef.mcState.mcPanel.mcSubmit._visible)
  242.       {
  243.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(1);
  244.       }
  245.       else
  246.       {
  247.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  248.       }
  249.       this.mcRef.mcState.mcPanel.txt_highScoreNumber.text = _loc4_;
  250.       this.mcRef.mcState.mcPanel.txt_highScoreName.text = _loc5_;
  251.       this.mcRef.mcState.mcPanel.txt_highScoreScore.text = _loc6_;
  252.       this.mcRef.mcState.mcPanel.txt_highScoreNumber.scroll = _loc7_;
  253.       this.mcRef.mcState.mcPanel.txt_highScoreName.scroll = _loc7_;
  254.       this.mcRef.mcState.mcPanel.txt_highScoreScore.scroll = _loc7_;
  255.    }
  256. }
  257.