home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / 05-11-10-1.swf / scripts / __Packages / CountDown.as < prev    next >
Encoding:
Text File  |  2005-11-18  |  1.5 KB  |  82 lines

  1. class CountDown
  2. {
  3.    var FRAMERATE = 36;
  4.    var etat = new String();
  5.    var oldEtat = new String();
  6.    var nom = new String();
  7.    var paused = new Boolean();
  8.    var nbItDone = new Number();
  9.    function CountDown(l_nom)
  10.    {
  11.       this.nom = l_nom;
  12.       this.etat = "Idle";
  13.       this.oldEtat = "Idle";
  14.       this.nbItDone = 0;
  15.       this.paused = false;
  16.    }
  17.    function EnterFrame()
  18.    {
  19.       if(!this.paused)
  20.       {
  21.          this[this.etat]();
  22.       }
  23.    }
  24.    function AddTime(l_nbSec)
  25.    {
  26.       this.nbItDone += l_nbSec * this.FRAMERATE;
  27.    }
  28.    function GetCurrentTime()
  29.    {
  30.       var _loc2_ = new Number();
  31.       if(this.etat == "Running")
  32.       {
  33.          _loc2_ = Math.round(this.nbItDone / this.FRAMERATE);
  34.       }
  35.       else
  36.       {
  37.          _loc2_ = null;
  38.       }
  39.       return _loc2_;
  40.    }
  41.    function GetName()
  42.    {
  43.       return this.nom;
  44.    }
  45.    function GetState()
  46.    {
  47.       return this.etat;
  48.    }
  49.    function Idle()
  50.    {
  51.    }
  52.    function Pause()
  53.    {
  54.       this.paused = true;
  55.    }
  56.    function Running()
  57.    {
  58.       if(this.nbItDone <= 0)
  59.       {
  60.          this.etat = "Idle";
  61.       }
  62.       else
  63.       {
  64.          this.nbItDone = this.nbItDone - 1;
  65.       }
  66.    }
  67.    function StartTimer(l_nbSeconds)
  68.    {
  69.       this.nbItDone = l_nbSeconds * this.FRAMERATE;
  70.       this.etat = "Running";
  71.    }
  72.    function StopTimer()
  73.    {
  74.       this.nbItDone = 0;
  75.       this.etat = "Idle";
  76.    }
  77.    function UnPause()
  78.    {
  79.       this.paused = false;
  80.    }
  81. }
  82.