home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / eolica.swf / scripts / frame_19 / DoAction.as
Encoding:
Text File  |  2005-07-26  |  1.5 KB  |  75 lines

  1. JetStreamTimer = function(mc)
  2. {
  3.    this.mc = mc;
  4.    this.mc.obj = this;
  5.    this.mc.initAllDigits = function(mc)
  6.    {
  7.       this.obj.initAllDigits(mc);
  8.    };
  9.    GAME.addListener(this);
  10. };
  11. t = JetStreamTimer.prototype;
  12. t.mc = false;
  13. t.numberFlipper = false;
  14. t.timeRemaining = 0;
  15. t.timeElapsed = 0;
  16. t.totalTime = 0;
  17. t.lastTime = 0;
  18. t.initAllDigits = function(mc)
  19. {
  20.    this.numberFlipper = new NumberFlipper(mc,2);
  21. };
  22. t.start = function(time)
  23. {
  24.    this.totalTime = time;
  25.    this.timeRemaining = this.totalTime;
  26.    this.timeElapsed = 0;
  27.    this.lastTime = getTimer() / 1000;
  28.    this.mc.onEnterFrame = function()
  29.    {
  30.       this.obj.timerLoop();
  31.    };
  32.    this.mc.gotoAndPlay("show");
  33. };
  34. t.stop = function()
  35. {
  36.    this.totalTime = 0;
  37.    this.timeRemaining = 0;
  38.    this.timeElapsed = 0;
  39.    this.lastTime = 0;
  40.    this.draw();
  41.    this.mc.gotoAndPlay("hide");
  42.    delete this.mc.onEnterFrame;
  43. };
  44. t.reset = function()
  45. {
  46. };
  47. t.timerLoop = function()
  48. {
  49.    var _loc2_ = getTimer() / 1000;
  50.    var _loc3_ = _loc2_ - this.lastTime;
  51.    this.lastTime = _loc2_;
  52.    this.timeElapsed += _loc3_;
  53.    this.timeRemaining = this.totalTime - this.timeElapsed;
  54.    this.timePer = this.timeRemaining / this.totalTime;
  55.    if(this.timeRemaining < 0)
  56.    {
  57.       GAME.turnOffJetStream();
  58.    }
  59.    this.draw();
  60. };
  61. t.draw = function()
  62. {
  63.    this.numberFlipper.showNum(Math.ceil(this.timeRemaining));
  64.    this.mc.time_out = this.timeRemaining;
  65. };
  66. t.onLevelStart = function()
  67. {
  68. };
  69. t.onLevelComplete = function()
  70. {
  71. };
  72. t.onLevelIncomplete = function()
  73. {
  74. };
  75.