home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / flameout.swf / scripts / __Packages / LRG / LRGAnimationAction.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  3.1 KB  |  107 lines

  1. class LRG.LRGAnimationAction extends LRG.LRGAction
  2. {
  3.    var m_sActionType;
  4.    var m_pFrameList;
  5.    var m_sName;
  6.    var m_fDirection;
  7.    var m_fCurrentFrameIndex;
  8.    var m_bIsLooping;
  9.    var m_fFPS;
  10.    function LRGAnimationAction(kAnimationParams)
  11.    {
  12.       super();
  13.       this.init(kAnimationParams);
  14.    }
  15.    function init(kAnimationParams)
  16.    {
  17.       if(kAnimationParams.m_sType == undefined && (this.m_sActionType == undefined || this.m_sActionType == "DEFAULT"))
  18.       {
  19.          kAnimationParams.m_sType = "FRAME_ANIMATION";
  20.       }
  21.       super.init(kAnimationParams);
  22.       if(kAnimationParams.m_fStartFrame != undefined && kAnimationParams.m_fEndFrame != undefined)
  23.       {
  24.          if(this.m_pFrameList == undefined)
  25.          {
  26.             this.m_pFrameList = new Array();
  27.          }
  28.          this.m_pFrameList.splice(0);
  29.          var _loc3_ = kAnimationParams.m_fStartFrame;
  30.          while(_loc3_ <= kAnimationParams.m_fEndFrame)
  31.          {
  32.             this.m_pFrameList.push(_loc3_);
  33.             _loc3_ = _loc3_ + 1;
  34.          }
  35.       }
  36.       else if(kAnimationParams.m_pFrameList != undefined)
  37.       {
  38.          delete this.m_pFrameList;
  39.          this.m_pFrameList = kAnimationParams.m_pFrameList.slice(0);
  40.       }
  41.       else if(this.m_pFrameList == undefined)
  42.       {
  43.          trace("Animation action " + this.m_sName + " specified with no frame list.");
  44.       }
  45.       if(kAnimationParams.m_fDirection != undefined)
  46.       {
  47.          this.m_fDirection = kAnimationParams.m_fDirection;
  48.       }
  49.       else if(this.m_fDirection == undefined)
  50.       {
  51.          this.m_fDirection = 1;
  52.       }
  53.       this.m_fCurrentFrameIndex = 0;
  54.       if(kAnimationParams.m_bLoop != undefined)
  55.       {
  56.          this.m_bIsLooping = kAnimationParams.m_bLoop;
  57.       }
  58.       else if(this.m_bIsLooping == undefined)
  59.       {
  60.          this.m_bIsLooping = false;
  61.       }
  62.    }
  63.    function reset(fCurrTime, kAnimationParams)
  64.    {
  65.       super.reset(fCurrTime,kAnimationParams);
  66.       if(this.m_fDirection > 0)
  67.       {
  68.          this.m_fCurrentFrameIndex = 0;
  69.       }
  70.       else
  71.       {
  72.          this.m_fCurrentFrameIndex = this.m_pFrameList.length - 1;
  73.       }
  74.    }
  75.    function doUpdate(fCurrTime, fDeltaTimeSecs, kClip)
  76.    {
  77.       var _loc3_ = fDeltaTimeSecs * this.m_fFPS;
  78.       this.m_fCurrentFrameIndex += this.m_fDirection * _loc3_;
  79.       var _loc4_ = Math.round(this.m_fCurrentFrameIndex);
  80.       if(_loc4_ < this.m_pFrameList.length)
  81.       {
  82.          var _loc2_ = this.m_pFrameList[Math.round(this.m_fCurrentFrameIndex)];
  83.       }
  84.       else
  85.       {
  86.          _loc2_ = this.m_pFrameList[this.m_pFrameList.length - 1];
  87.       }
  88.       kClip.gotoAndStop(_loc2_);
  89.       if(!this.m_bIsLooping)
  90.       {
  91.          if(this.m_fCurrentFrameIndex < 0 || this.m_fCurrentFrameIndex >= this.m_pFrameList.length)
  92.          {
  93.             return true;
  94.          }
  95.       }
  96.       else if(this.m_fCurrentFrameIndex < 0)
  97.       {
  98.          this.m_fCurrentFrameIndex = this.m_pFrameList.length - 1;
  99.       }
  100.       else if(this.m_fCurrentFrameIndex >= this.m_pFrameList.length)
  101.       {
  102.          this.m_fCurrentFrameIndex = 0;
  103.       }
  104.       return false;
  105.    }
  106. }
  107.