home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / kung_fu.swf / scripts / __Packages / ds / controls / Timer.as < prev   
Encoding:
Text File  |  2006-06-13  |  815 b   |  44 lines

  1. class ds.controls.Timer
  2. {
  3.    var func;
  4.    var interval;
  5.    var m_timerId = -1;
  6.    function Timer(f, i)
  7.    {
  8.       if(f)
  9.       {
  10.          this.func = f;
  11.       }
  12.       if(i)
  13.       {
  14.          this.interval = i;
  15.       }
  16.       this.m_timerId = -1;
  17.    }
  18.    function start(_func, _interval)
  19.    {
  20.       if(this.m_timerId != -1)
  21.       {
  22.          this.stop();
  23.       }
  24.       if(_func && this.func != _func)
  25.       {
  26.          this.func = _func;
  27.       }
  28.       if(_interval && this.interval != _interval)
  29.       {
  30.          this.interval = _interval;
  31.       }
  32.       this.m_timerId = setInterval(this.func,this.interval);
  33.    }
  34.    function stop()
  35.    {
  36.       clearInterval(this.m_timerId);
  37.       this.m_timerId = -1;
  38.    }
  39.    function isRunning()
  40.    {
  41.       return this.m_timerId != -1;
  42.    }
  43. }
  44.