home *** CD-ROM | disk | FTP | other *** search
/ FCE Gold Plus / GOLD.iso / pc / fscommand / linux / main.swf / scripts / __Packages / com / comp / Timer.as < prev    next >
Encoding:
Text File  |  2007-09-06  |  4.6 KB  |  179 lines

  1. class com.comp.Timer
  2. {
  3.    var c_objInterval;
  4.    var c_mcSourceRef;
  5.    var c_objTestRef;
  6.    var c_iTimerDuration;
  7.    var c_iTotalTime;
  8.    var c_iMins;
  9.    var c_boolVar = true;
  10.    function Timer(_objRoot, _iTotTime, _iTotSecTime, _strSourceClip, _strMinField, _objTestRef)
  11.    {
  12.       var _loc1_ = this;
  13.       _loc1_.c_objRef = _objRoot;
  14.       _loc1_.c_mcSourceRef = _objRoot[_strSourceClip];
  15.       _loc1_.c_txtMinRef = _loc1_.c_mcSourceRef[_strMinField];
  16.       _loc1_.c_iTotalTime = _iTotTime;
  17.       _loc1_.c_objTestRef = _objTestRef;
  18.       _loc1_.init(_iTotTime,_iTotSecTime);
  19.    }
  20.    function init(_iMinutes, _iSeconds)
  21.    {
  22.       var _loc1_ = this;
  23.       _loc1_.c_iMins = Number(_iMinutes);
  24.       _loc1_.c_iTimerDuration = Number(_iMinutes);
  25.       _loc1_.c_iSecs = Number(_iSeconds);
  26.       _loc1_.c_iMins = _loc1_.c_iMins - 1;
  27.       _loc1_.changedTime();
  28.       _loc1_.c_txtMinRef.htmlText = "<b>" + _loc1_.c_iChangedMins + "</b>" + " mins";
  29.       if(_loc1_.c_iMins < 10)
  30.       {
  31.          _loc1_.c_iMins = "0" + _loc1_.c_iMins;
  32.       }
  33.       _loc1_.arrange();
  34.    }
  35.    function arrange()
  36.    {
  37.       this.startTimer();
  38.    }
  39.    function startTimer()
  40.    {
  41.       var _loc1_ = this;
  42.       _loc1_.c_objInterval = setInterval(_loc1_.showTimer,1000,_loc1_);
  43.    }
  44.    function stopTimer()
  45.    {
  46.       clearInterval(this.c_objInterval);
  47.    }
  48.    function showTimer(_objRef)
  49.    {
  50.       with(_objRef)
  51.       {
  52.          if(c_iSecs <= 0)
  53.          {
  54.             c_iSecs = 60;
  55.             actualTime();
  56.          }
  57.          c_iSecs--;
  58.          if(c_iSecs < 10)
  59.          {
  60.             c_iSecs = "0" + c_iSecs;
  61.          }
  62.          if(c_iMins == 15 || c_iMins == 5)
  63.          {
  64.             if(c_iMins == 5)
  65.             {
  66.                c_blnPopUp = false;
  67.             }
  68.             if(!c_blnPopUp && c_iSecs == 0)
  69.             {
  70.                _objRef = _level101.mc_PopUp;
  71.                _objRef.gotoAndStop("timeleft");
  72.                c_blnPopUp = true;
  73.                _objRef._x = 232.9;
  74.                _objRef._y = 181.4;
  75.                _objRef.txt_TimeLeft.text = Number(c_iMins) + " mins remaining";
  76.                _objRef.btn_backtotest.onRelease = function()
  77.                {
  78.                   _objRef.gotoAndStop("blank");
  79.                };
  80.             }
  81.          }
  82.          if(c_iSecs <= 0 && c_iMins <= 0)
  83.          {
  84.             gameOver();
  85.             stopTimer();
  86.          }
  87.       }
  88.       _objRef.setEvents(_objRef);
  89.       _objRef.setTimer();
  90.       _objRef.getminsTime();
  91.    }
  92.    function setEvents(_objRef)
  93.    {
  94.       this.c_mcSourceRef.onRollOver = function()
  95.       {
  96.          _objRef.c_boolVar = false;
  97.          _objRef.setTimer();
  98.       };
  99.       this.c_mcSourceRef.onRollOut = function()
  100.       {
  101.          _objRef.c_boolVar = true;
  102.          _objRef.setTimer();
  103.       };
  104.    }
  105.    function setTimer()
  106.    {
  107.       var _loc1_ = this;
  108.       if(_loc1_.c_iMins <= 10)
  109.       {
  110.          _loc1_.c_txtMinRef.textColor = 65295;
  111.       }
  112.       if(_loc1_.c_boolVar)
  113.       {
  114.          _loc1_.c_txtMinRef.htmlText = "<p><b>" + _loc1_.c_iChangedMins + "</b>" + " mins" + "</p>";
  115.       }
  116.       else
  117.       {
  118.          _loc1_.c_txtMinRef.htmlText = "<p align=\'center\'><b>" + _loc1_.c_iMins + ":" + _loc1_.c_iSecs + "</b></p>";
  119.       }
  120.    }
  121.    function actualTime()
  122.    {
  123.       var _loc1_ = this;
  124.       _loc1_.c_iMins = _loc1_.c_iMins - 1;
  125.       if(_loc1_.c_iMins < 10)
  126.       {
  127.          _loc1_.c_iMins = "0" + _loc1_.c_iMins;
  128.       }
  129.       _loc1_.changedTime();
  130.       return _loc1_.c_iMins;
  131.    }
  132.    function changedTime()
  133.    {
  134.       var _loc2_ = this;
  135.       var _loc1_ = Number(_loc2_.c_iMins) + Number(1);
  136.       if(_loc1_ < 10)
  137.       {
  138.          _loc2_.c_iChangedMins = "0" + _loc1_;
  139.       }
  140.       else
  141.       {
  142.          _loc2_.c_iChangedMins = _loc1_;
  143.       }
  144.       return _loc2_.c_iChangedMins;
  145.    }
  146.    function gameOver()
  147.    {
  148.       trace("Game Over");
  149.       clearInterval(this.c_objInterval);
  150.       this.c_objTestRef.popupNo();
  151.    }
  152.    function alerts()
  153.    {
  154.       trace("YOU HAVE ONLY 15 MINS");
  155.    }
  156.    function resetTimer()
  157.    {
  158.       this.init(this.c_iTimerDuration);
  159.    }
  160.    function destroyTimer()
  161.    {
  162.       clearInterval(this.c_objInterval);
  163.       this.c_mcSourceRef.removeMovieClip();
  164.    }
  165.    function getMinsTime()
  166.    {
  167.       var _loc1_ = undefined;
  168.       _loc1_ = Number(this.c_iTotalTime) - Math.floor(Number(this.c_iMins));
  169.       return _loc1_;
  170.    }
  171.    function getSecTime()
  172.    {
  173.       var _loc1_ = this;
  174.       var _min = Math.floor(_loc1_.c_iMins / 60);
  175.       var _sec = _loc1_.c_iMins % 60;
  176.       return _loc1_.c_iMins + "." + _loc1_.c_iSecs;
  177.    }
  178. }
  179.