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

  1. ScoreDisplay = function(mc)
  2. {
  3.    this.mc = mc;
  4.    this.mc.obj = this;
  5.    GAME.addListener(this);
  6. };
  7. t = ScoreDisplay.prototype;
  8. t.mc = false;
  9. t.curNum = 0;
  10. t.displayNum = 0;
  11. t.destNum = 0;
  12. t.lastSoundNum = 0;
  13. t.showScore = function(score)
  14. {
  15.    Audio.play("geo_counter_1_snd");
  16.    this.lastSoundNum = this.curNum;
  17.    this.destNum = score;
  18.    this.startLoop();
  19. };
  20. t.startLoop = function()
  21. {
  22.    this.mc.onEnterFrame = function()
  23.    {
  24.       this.obj.loop();
  25.    };
  26. };
  27. t.stopLoop = function()
  28. {
  29.    delete this.mc.onEnterFrame;
  30. };
  31. t.loop = function()
  32. {
  33.    this.curNum += (this.destNum - this.curNum) * 0.2;
  34.    this.displayNum = "" + Math.round(this.curNum);
  35.    if(this.displayNum == this.destNum)
  36.    {
  37.       this.stopLoop();
  38.       this.curNum = this.destNum;
  39.    }
  40.    if(this.curNum > 1000)
  41.    {
  42.       var _loc2_ = this.displayNum.length;
  43.       this.displayNum = this.displayNum.substring(0,_loc2_ - 3) + "," + this.displayNum.substring(_loc2_ - 3,_loc2_);
  44.    }
  45.    this.mc.text = this.displayNum;
  46.    if(this.curNum - this.lastSoundNum > 50)
  47.    {
  48.       this.lastSoundNum = this.curNum;
  49.       Audio.play("geo_counter_1_snd");
  50.    }
  51. };
  52.