home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / Kung_Fu.swf / scripts / DefineSprite_1811 / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2007-09-27  |  1.2 KB  |  65 lines

  1. mbenneyTimer = function()
  2. {
  3.    this.reset();
  4. };
  5. mT = mbenneyTimer.prototype;
  6. mT.reset = function()
  7. {
  8.    this.oldTime = 0;
  9.    this.pause = true;
  10.    this.totalTime = 0;
  11. };
  12. mT.stop = function()
  13. {
  14.    if(!this.pause)
  15.    {
  16.       this.pause = true;
  17.       this.totalTime += getTimer() - this.oldTime;
  18.    }
  19. };
  20. mT.start = function()
  21. {
  22.    if(this.pause)
  23.    {
  24.       this.pause = false;
  25.       this.oldTime = getTimer();
  26.    }
  27. };
  28. mT.getMili = function()
  29. {
  30.    var returnTime = this.totalTime;
  31.    if(!this.pause)
  32.    {
  33.       returnTime += getTimer() - this.oldTime;
  34.    }
  35.    return returnTime;
  36. };
  37. mT.getSecs = function()
  38. {
  39.    var returnTime = this.totalTime / 1000;
  40.    if(!this.pause)
  41.    {
  42.       returnTime += (getTimer() - this.oldTime) / 1000;
  43.    }
  44.    return Math.round(returnTime);
  45. };
  46. mT.getMins = function()
  47. {
  48.    var returnTime = this.totalTime / 1000;
  49.    if(!this.pause)
  50.    {
  51.       returnTime += (getTimer() - this.oldTime) / 1000 / 60;
  52.    }
  53.    return Math.round(returnTime);
  54. };
  55. mT.getCount = function(secs)
  56. {
  57.    var returnTime = this.totalTime;
  58.    if(!this.pause)
  59.    {
  60.       returnTime += (getTimer() - this.oldTime) / 1000;
  61.    }
  62.    var count = secs - returnTime;
  63.    return Math.round(count);
  64. };
  65.