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

  1. WindGauge = function(mc)
  2. {
  3.    this.mc = mc;
  4.    this.mc.obj = this;
  5.    GAME.addListener(this);
  6. };
  7. t = WindGauge.prototype;
  8. t.mc = false;
  9. t.minAngle = -90;
  10. t.maxAngle = 90;
  11. t.difAngle = t.maxAngle - t.minAngle;
  12. t.windiesMinFrame = 1;
  13. t.windiesMaxFrame = 100;
  14. t.windiesDifFrame = t.windiesMaxFrame - t.windiesMinFrame;
  15. t.windPer = 0;
  16. t.destRot = 0;
  17. t.curArrowRot = 0;
  18. t.curOLRot = 0;
  19. t.startLoop = function()
  20. {
  21.    this.mc.onEnterFrame = function()
  22.    {
  23.       this.obj.loop();
  24.    };
  25. };
  26. t.stopLoop = function()
  27. {
  28.    delete this.mc.onEnterFrame;
  29. };
  30. t.loop = function()
  31. {
  32.    var _loc2_ = this.destRot;
  33.    this.curArrowRot += (_loc2_ - this.curArrowRot) * 0.3;
  34.    this.curOLRot += (this.curArrowRot - this.curOLRot) * 0.1;
  35.    if(Math.abs(this.curOLRot - _loc2_) < 0.5)
  36.    {
  37.       this.curArrowRot = _loc2_;
  38.       this.curOLRot = _loc2_;
  39.       this.stopLoop();
  40.    }
  41.    this.windPer = (this.curArrowRot - this.minAngle) / this.difAngle;
  42.    this.mc.windper_out = this.windPer;
  43.    this.mc.arrow_mc._rotation = this.curArrowRot;
  44.    this.mc.ol_mc._rotation = this.curOLRot;
  45. };
  46. t.onWindDirectionChange = function(direction)
  47. {
  48.    this.destRot = direction;
  49.    this.startLoop();
  50. };
  51.