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

  1. class LRG.LRGMovieClip extends MovieClip
  2. {
  3.    var m_kActionsList;
  4.    var m_pActiveActions;
  5.    var m_kClipClock;
  6.    var onEnterFrame;
  7.    function LRGMovieClip()
  8.    {
  9.       super();
  10.       if(this._name == "m_kUpsellBackground")
  11.       {
  12.          trace("created a m_kUpsellBackground");
  13.       }
  14.       this.stop();
  15.       this.init();
  16.    }
  17.    function init()
  18.    {
  19.       this.m_kActionsList = new Object();
  20.       this.m_pActiveActions = new Array();
  21.       this.m_kClipClock = undefined;
  22.    }
  23.    function setClock(kClockObject)
  24.    {
  25.       this.m_kClipClock = kClockObject;
  26.    }
  27.    function getClock()
  28.    {
  29.       return this.m_kClipClock;
  30.    }
  31.    function addAction(kActionObject)
  32.    {
  33.       if(this.m_kActionsList[kActionObject.getName()] != undefined)
  34.       {
  35.          this.removeAction(kActionObject.getName());
  36.       }
  37.       this.m_kActionsList[kActionObject.getName()] = kActionObject;
  38.    }
  39.    function removeAction(sActionKey)
  40.    {
  41.       if(this.m_kActionsList[sActionKey] != undefined)
  42.       {
  43.          if(this.m_pActiveActions.getIndex(sActionKey) != -1)
  44.          {
  45.             this.stopAction(sActionKey,false);
  46.          }
  47.          delete this.m_kActionsList[sActionKey];
  48.          if(this.m_pActiveActions.length <= 0)
  49.          {
  50.             this.onEnterFrame = undefined;
  51.          }
  52.       }
  53.    }
  54.    function removeAllActions()
  55.    {
  56.       var _loc3_ = new Array();
  57.       for(var _loc4_ in this.m_kActionsList)
  58.       {
  59.          _loc3_.push(_loc4_);
  60.       }
  61.       var _loc2_ = 0;
  62.       while(_loc2_ < _loc3_.length)
  63.       {
  64.          this.removeAction(_loc3_[_loc2_]);
  65.          _loc2_ = _loc2_ + 1;
  66.       }
  67.       false;
  68.    }
  69.    function startAction(sActionKey, kActionParams, bExclusiveType)
  70.    {
  71.       if(sActionKey == "THROB_IN")
  72.       {
  73.          trace("starting THROB_IN");
  74.       }
  75.       var _loc3_ = undefined;
  76.       if((_loc3_ = this.m_kActionsList[sActionKey]) == undefined)
  77.       {
  78.          trace(this + ": An attempt was made to start the undefined action " + sActionKey);
  79.          return undefined;
  80.       }
  81.       if(this.m_pActiveActions.getIndex(sActionKey) != -1)
  82.       {
  83.          return undefined;
  84.       }
  85.       if(bExclusiveType)
  86.       {
  87.          this.stopActionsOfType(_loc3_.getType());
  88.       }
  89.       _loc3_.reset(this.getClipTime(),kActionParams);
  90.       this.m_pActiveActions.push(sActionKey);
  91.       if(sActionKey == "THROB_IN")
  92.       {
  93.          trace("pushed " + this.m_pActiveActions);
  94.       }
  95.       this.onEnterFrame = this.LRGOnEnterFrame;
  96.    }
  97.    function stopActionsOfType(sActionType)
  98.    {
  99.       var _loc5_ = this.m_pActiveActions.slice(0);
  100.       var _loc2_ = 0;
  101.       while(_loc2_ < _loc5_.length)
  102.       {
  103.          var _loc3_ = _loc5_[_loc2_];
  104.          var _loc4_ = this.m_kActionsList[_loc3_];
  105.          if(_loc4_.getType() == sActionType)
  106.          {
  107.             this.stopAction(_loc3_,false);
  108.          }
  109.          _loc2_ = _loc2_ + 1;
  110.       }
  111.       false;
  112.    }
  113.    function stopAction(sActionKey, bCompleted)
  114.    {
  115.       var _loc2_ = this.m_pActiveActions.removeData(sActionKey);
  116.       delete this.m_pActiveActions;
  117.       this.m_pActiveActions = _loc2_;
  118.       if(!this.isActionActive())
  119.       {
  120.          this.onEnterFrame = undefined;
  121.       }
  122.       if(bCompleted)
  123.       {
  124.          this.onActionCompleted(sActionKey);
  125.       }
  126.    }
  127.    function stopAllActions()
  128.    {
  129.       var _loc3_ = this.m_pActiveActions.slice(0);
  130.       var _loc2_ = 0;
  131.       while(_loc2_ < _loc3_.length)
  132.       {
  133.          this.stopAction(_loc3_[_loc2_],false);
  134.          _loc2_ = _loc2_ + 1;
  135.       }
  136.       false;
  137.    }
  138.    function getActionsList()
  139.    {
  140.       return this.m_kActionsList;
  141.    }
  142.    function getActiveActions()
  143.    {
  144.       return this.m_pActiveActions;
  145.    }
  146.    function getAction(sActionKey)
  147.    {
  148.       return this.m_kActionsList[sActionKey];
  149.    }
  150.    function isActionActive()
  151.    {
  152.       return this.m_pActiveActions.length >= 1;
  153.    }
  154.    function playAnimation(sName, fFps, fStartFrame, fEndFrame, bLoop, fDirection)
  155.    {
  156.       var _loc2_ = new Object();
  157.       _loc2_.m_sName = sName;
  158.       _loc2_.m_fFPS = fFps;
  159.       _loc2_.m_fStartFrame = fStartFrame;
  160.       _loc2_.m_fEndFrame = fEndFrame;
  161.       _loc2_.m_bLoop = bLoop;
  162.       _loc2_.m_fDirection = fDirection;
  163.       var _loc3_ = new LRG.LRGAnimationAction(_loc2_);
  164.       this.addAction(_loc3_);
  165.       this.startAction(sName,null,true);
  166.    }
  167.    function play(fFps, bLoop)
  168.    {
  169.       if(this._name == "m_kAnimation")
  170.       {
  171.          trace("LRGMovieclip play for mk animation");
  172.       }
  173.       if(fFps == undefined)
  174.       {
  175.          fFps = 30;
  176.       }
  177.       if(bLoop == undefined)
  178.       {
  179.          bLoop = false;
  180.       }
  181.       this.playAnimation("DEFAULT_FULL_FRAME_ANIMATION",fFps,1,this._totalframes,bLoop,1);
  182.    }
  183.    function LRGOnEnterFrame()
  184.    {
  185.       if(this.isClockRunning())
  186.       {
  187.          this.LRGUpdateActions();
  188.          this.doEnterFrame();
  189.       }
  190.    }
  191.    function LRGUpdateActions()
  192.    {
  193.       var _loc8_ = this.getClipTime();
  194.       var _loc5_ = new Array();
  195.       var _loc6_ = new Array();
  196.       var _loc4_ = undefined;
  197.       var _loc3_ = 0;
  198.       while(_loc3_ < this.m_pActiveActions.length)
  199.       {
  200.          _loc4_ = this.m_pActiveActions[_loc3_];
  201.          var _loc7_ = this.m_kActionsList[_loc4_].update(_loc8_,this);
  202.          if(_loc7_)
  203.          {
  204.             _loc5_.push(_loc4_);
  205.             var _loc2_ = this.m_kActionsList[_loc4_].getNext();
  206.             if(_loc2_ != undefined && this.m_kActionsList[_loc2_] != undefined)
  207.             {
  208.                _loc6_.push(_loc2_);
  209.             }
  210.          }
  211.          _loc3_ = _loc3_ + 1;
  212.       }
  213.       _loc3_ = 0;
  214.       while(_loc3_ < _loc5_.length)
  215.       {
  216.          this.stopAction(_loc5_[_loc3_],true);
  217.          _loc3_ = _loc3_ + 1;
  218.       }
  219.       false;
  220.       _loc3_ = 0;
  221.       while(_loc3_ < _loc6_.length)
  222.       {
  223.          this.startAction(_loc6_[_loc3_]);
  224.          _loc3_ = _loc3_ + 1;
  225.       }
  226.       false;
  227.    }
  228.    function onActionCompleted(sActionKey)
  229.    {
  230.       this._parent.onActionCompleted(sActionKey);
  231.    }
  232.    function doEnterFrame()
  233.    {
  234.    }
  235.    function getClipTime()
  236.    {
  237.       if(this.m_kClipClock)
  238.       {
  239.          return this.m_kClipClock.getTime();
  240.       }
  241.       return getTimer() / 1000;
  242.    }
  243.    function isClockRunning()
  244.    {
  245.       if(!this.m_kClipClock)
  246.       {
  247.          return true;
  248.       }
  249.       return this.m_kClipClock.isRunning();
  250.    }
  251. }
  252.