home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 January / ME_2012_01.iso / Galileo-Video / system / ChromeLinux.swf / scripts / com / greensock / TweenLite.as < prev    next >
Encoding:
Text File  |  2010-11-16  |  16.5 KB  |  519 lines

  1. package com.greensock
  2. {
  3.    import com.greensock.core.*;
  4.    import flash.display.*;
  5.    import flash.events.*;
  6.    import flash.utils.*;
  7.    
  8.    public class TweenLite extends TweenCore
  9.    {
  10.       public static var rootTimeline:SimpleTimeline;
  11.       
  12.       public static var onPluginEvent:Function;
  13.       
  14.       public static var rootFramesTimeline:SimpleTimeline;
  15.       
  16.       public static var overwriteManager:Object;
  17.       
  18.       public static var rootFrame:Number;
  19.       
  20.       public static const version:Number = 11.36;
  21.       
  22.       public static var plugins:Object = {};
  23.       
  24.       public static var fastEaseLookup:Dictionary = new Dictionary(false);
  25.       
  26.       public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
  27.       
  28.       public static var defaultEase:Function = TweenLite.easeOut;
  29.       
  30.       public static var masterList:Dictionary = new Dictionary(false);
  31.       
  32.       private static var _shape:Shape = new Shape();
  33.       
  34.       protected static var _reservedProps:Object = {
  35.          "ease":1,
  36.          "delay":1,
  37.          "overwrite":1,
  38.          "onComplete":1,
  39.          "onCompleteParams":1,
  40.          "useFrames":1,
  41.          "runBackwards":1,
  42.          "startAt":1,
  43.          "onUpdate":1,
  44.          "onUpdateParams":1,
  45.          "roundProps":1,
  46.          "onStart":1,
  47.          "onStartParams":1,
  48.          "onInit":1,
  49.          "onInitParams":1,
  50.          "onReverseComplete":1,
  51.          "onReverseCompleteParams":1,
  52.          "onRepeat":1,
  53.          "onRepeatParams":1,
  54.          "proxiedEase":1,
  55.          "easeParams":1,
  56.          "yoyo":1,
  57.          "onCompleteListener":1,
  58.          "onUpdateListener":1,
  59.          "onStartListener":1,
  60.          "onReverseCompleteListener":1,
  61.          "onRepeatListener":1,
  62.          "orientToBezier":1,
  63.          "timeScale":1,
  64.          "immediateRender":1,
  65.          "repeat":1,
  66.          "repeatDelay":1,
  67.          "timeline":1,
  68.          "data":1,
  69.          "paused":1
  70.       };
  71.       
  72.       protected var _hasPlugins:Boolean;
  73.       
  74.       public var propTweenLookup:Object;
  75.       
  76.       public var cachedPT1:PropTween;
  77.       
  78.       protected var _overwrite:uint;
  79.       
  80.       protected var _ease:Function;
  81.       
  82.       public var target:Object;
  83.       
  84.       public var ratio:Number = 0;
  85.       
  86.       protected var _overwrittenProps:Object;
  87.       
  88.       protected var _notifyPluginsOfEnabled:Boolean;
  89.       
  90.       public function TweenLite(param1:Object, param2:Number, param3:Object)
  91.       {
  92.          var _loc5_:TweenLite = null;
  93.          super(param2,param3);
  94.          this.target = param1;
  95.          if(this.target is TweenCore && Boolean(this.vars.timeScale))
  96.          {
  97.             this.cachedTimeScale = 1;
  98.          }
  99.          propTweenLookup = {};
  100.          _ease = defaultEase;
  101.          _overwrite = Number(param3.overwrite) <= -1 || !overwriteManager.enabled && param3.overwrite > 1 ? uint(overwriteManager.mode) : uint(int(param3.overwrite));
  102.          var _loc4_:Array = masterList[param1];
  103.          if(!_loc4_)
  104.          {
  105.             masterList[param1] = [this];
  106.          }
  107.          else if(_overwrite == 1)
  108.          {
  109.             for each(_loc5_ in _loc4_)
  110.             {
  111.                if(!_loc5_.gc)
  112.                {
  113.                   _loc5_.setEnabled(false,false);
  114.                }
  115.             }
  116.             masterList[param1] = [this];
  117.          }
  118.          else
  119.          {
  120.             _loc4_[_loc4_.length] = this;
  121.          }
  122.          if(this.active || Boolean(this.vars.immediateRender))
  123.          {
  124.             renderTime(0,false,true);
  125.          }
  126.       }
  127.       
  128.       public static function initClass() : void
  129.       {
  130.          rootFrame = 0;
  131.          rootTimeline = new SimpleTimeline(null);
  132.          rootFramesTimeline = new SimpleTimeline(null);
  133.          rootTimeline.cachedStartTime = getTimer() * 0.001;
  134.          rootFramesTimeline.cachedStartTime = rootFrame;
  135.          rootTimeline.autoRemoveChildren = true;
  136.          rootFramesTimeline.autoRemoveChildren = true;
  137.          _shape.addEventListener(Event.ENTER_FRAME,updateAll,false,0,true);
  138.          if(overwriteManager == null)
  139.          {
  140.             overwriteManager = {
  141.                "mode":1,
  142.                "enabled":false
  143.             };
  144.          }
  145.       }
  146.       
  147.       public static function killTweensOf(param1:Object, param2:Boolean = false, param3:Object = null) : void
  148.       {
  149.          var _loc4_:Array = null;
  150.          var _loc5_:int = 0;
  151.          var _loc6_:TweenLite = null;
  152.          if(param1 in masterList)
  153.          {
  154.             _loc4_ = masterList[param1];
  155.             _loc5_ = int(_loc4_.length);
  156.             while(--_loc5_ > -1)
  157.             {
  158.                _loc6_ = _loc4_[_loc5_];
  159.                if(!_loc6_.gc)
  160.                {
  161.                   if(param2)
  162.                   {
  163.                      _loc6_.complete(false,false);
  164.                   }
  165.                   if(param3 != null)
  166.                   {
  167.                      _loc6_.killVars(param3);
  168.                   }
  169.                   if(param3 == null || _loc6_.cachedPT1 == null && _loc6_.initted)
  170.                   {
  171.                      _loc6_.setEnabled(false,false);
  172.                   }
  173.                }
  174.             }
  175.             if(param3 == null)
  176.             {
  177.                delete masterList[param1];
  178.             }
  179.          }
  180.       }
  181.       
  182.       public static function from(param1:Object, param2:Number, param3:Object) : TweenLite
  183.       {
  184.          param3.runBackwards = true;
  185.          if(!("immediateRender" in param3))
  186.          {
  187.             param3.immediateRender = true;
  188.          }
  189.          return new TweenLite(param1,param2,param3);
  190.       }
  191.       
  192.       protected static function easeOut(param1:Number, param2:Number, param3:Number, param4:Number) : Number
  193.       {
  194.          return 1 - (param1 = 1 - param1 / param4) * param1;
  195.       }
  196.       
  197.       public static function delayedCall(param1:Number, param2:Function, param3:Array = null, param4:Boolean = false) : TweenLite
  198.       {
  199.          return new TweenLite(param2,0,{
  200.             "delay":param1,
  201.             "onComplete":param2,
  202.             "onCompleteParams":param3,
  203.             "immediateRender":false,
  204.             "useFrames":param4,
  205.             "overwrite":0
  206.          });
  207.       }
  208.       
  209.       protected static function updateAll(param1:Event = null) : void
  210.       {
  211.          var _loc2_:Dictionary = null;
  212.          var _loc3_:Object = null;
  213.          var _loc4_:Array = null;
  214.          var _loc5_:int = 0;
  215.          rootTimeline.renderTime((getTimer() * 0.001 - rootTimeline.cachedStartTime) * rootTimeline.cachedTimeScale,false,false);
  216.          ++rootFrame;
  217.          rootFramesTimeline.renderTime((rootFrame - rootFramesTimeline.cachedStartTime) * rootFramesTimeline.cachedTimeScale,false,false);
  218.          if(!(rootFrame % 60))
  219.          {
  220.             _loc2_ = masterList;
  221.             for(_loc3_ in _loc2_)
  222.             {
  223.                _loc4_ = _loc2_[_loc3_];
  224.                _loc5_ = int(_loc4_.length);
  225.                while(--_loc5_ > -1)
  226.                {
  227.                   if(TweenLite(_loc4_[_loc5_]).gc)
  228.                   {
  229.                      _loc4_.splice(_loc5_,1);
  230.                   }
  231.                }
  232.                if(_loc4_.length == 0)
  233.                {
  234.                   delete _loc2_[_loc3_];
  235.                }
  236.             }
  237.          }
  238.       }
  239.       
  240.       public static function to(param1:Object, param2:Number, param3:Object) : TweenLite
  241.       {
  242.          return new TweenLite(param1,param2,param3);
  243.       }
  244.       
  245.       protected function easeProxy(param1:Number, param2:Number, param3:Number, param4:Number) : Number
  246.       {
  247.          return this.vars.proxiedEase.apply(null,arguments.concat(this.vars.easeParams));
  248.       }
  249.       
  250.       override public function renderTime(param1:Number, param2:Boolean = false, param3:Boolean = false) : void
  251.       {
  252.          var _loc4_:Boolean = false;
  253.          var _loc5_:Number = this.cachedTime;
  254.          if(param1 >= this.cachedDuration)
  255.          {
  256.             this.cachedTotalTime = this.cachedTime = this.cachedDuration;
  257.             this.ratio = 1;
  258.             _loc4_ = true;
  259.             if(this.cachedDuration == 0)
  260.             {
  261.                if((param1 == 0 || _rawPrevTime < 0) && _rawPrevTime != param1)
  262.                {
  263.                   param3 = true;
  264.                }
  265.                _rawPrevTime = param1;
  266.             }
  267.          }
  268.          else if(param1 <= 0)
  269.          {
  270.             this.cachedTotalTime = this.cachedTime = this.ratio = 0;
  271.             if(param1 < 0)
  272.             {
  273.                this.active = false;
  274.                if(this.cachedDuration == 0)
  275.                {
  276.                   if(_rawPrevTime > 0)
  277.                   {
  278.                      param3 = true;
  279.                      _loc4_ = true;
  280.                   }
  281.                   _rawPrevTime = param1;
  282.                }
  283.             }
  284.             if(this.cachedReversed && _loc5_ != 0)
  285.             {
  286.                _loc4_ = true;
  287.             }
  288.          }
  289.          else
  290.          {
  291.             this.cachedTotalTime = this.cachedTime = param1;
  292.             this.ratio = _ease(param1,0,1,this.cachedDuration);
  293.          }
  294.          if(this.cachedTime == _loc5_ && !param3)
  295.          {
  296.             return;
  297.          }
  298.          if(!this.initted)
  299.          {
  300.             init();
  301.             if(!_loc4_ && Boolean(this.cachedTime))
  302.             {
  303.                this.ratio = _ease(this.cachedTime,0,1,this.cachedDuration);
  304.             }
  305.          }
  306.          if(!this.active && !this.cachedPaused)
  307.          {
  308.             this.active = true;
  309.          }
  310.          if(_loc5_ == 0 && this.vars.onStart && this.cachedTime != 0 && !param2)
  311.          {
  312.             this.vars.onStart.apply(null,this.vars.onStartParams);
  313.          }
  314.          var _loc6_:PropTween = this.cachedPT1;
  315.          while(_loc6_)
  316.          {
  317.             _loc6_.target[_loc6_.property] = _loc6_.start + this.ratio * _loc6_.change;
  318.             _loc6_ = _loc6_.nextNode;
  319.          }
  320.          if(_hasUpdate && !param2)
  321.          {
  322.             this.vars.onUpdate.apply(null,this.vars.onUpdateParams);
  323.          }
  324.          if(_loc4_)
  325.          {
  326.             if(_hasPlugins && Boolean(this.cachedPT1))
  327.             {
  328.                onPluginEvent("onComplete",this);
  329.             }
  330.             complete(true,param2);
  331.          }
  332.       }
  333.       
  334.       override public function setEnabled(param1:Boolean, param2:Boolean = false) : Boolean
  335.       {
  336.          var _loc3_:Array = null;
  337.          if(param1)
  338.          {
  339.             _loc3_ = TweenLite.masterList[this.target];
  340.             if(!_loc3_)
  341.             {
  342.                TweenLite.masterList[this.target] = [this];
  343.             }
  344.             else
  345.             {
  346.                _loc3_[_loc3_.length] = this;
  347.             }
  348.          }
  349.          super.setEnabled(param1,param2);
  350.          if(_notifyPluginsOfEnabled && Boolean(this.cachedPT1))
  351.          {
  352.             return onPluginEvent(param1 ? "onEnable" : "onDisable",this);
  353.          }
  354.          return false;
  355.       }
  356.       
  357.       protected function init() : void
  358.       {
  359.          var _loc1_:String = null;
  360.          var _loc2_:int = 0;
  361.          var _loc3_:* = undefined;
  362.          var _loc4_:Boolean = false;
  363.          var _loc5_:Array = null;
  364.          var _loc6_:PropTween = null;
  365.          if(this.vars.onInit)
  366.          {
  367.             this.vars.onInit.apply(null,this.vars.onInitParams);
  368.          }
  369.          if(typeof this.vars.ease == "function")
  370.          {
  371.             _ease = this.vars.ease;
  372.          }
  373.          if(this.vars.easeParams)
  374.          {
  375.             this.vars.proxiedEase = _ease;
  376.             _ease = easeProxy;
  377.          }
  378.          this.cachedPT1 = null;
  379.          this.propTweenLookup = {};
  380.          for(_loc1_ in this.vars)
  381.          {
  382.             if(!(_loc1_ in _reservedProps && !(_loc1_ == "timeScale" && this.target is TweenCore)))
  383.             {
  384.                if(_loc1_ in plugins && Boolean((_loc3_ = new (plugins[_loc1_] as Class)()).onInitTween(this.target,this.vars[_loc1_],this)))
  385.                {
  386.                   this.cachedPT1 = new PropTween(_loc3_,"changeFactor",0,1,_loc3_.overwriteProps.length == 1 ? _loc3_.overwriteProps[0] : "_MULTIPLE_",true,this.cachedPT1);
  387.                   if(this.cachedPT1.name == "_MULTIPLE_")
  388.                   {
  389.                      _loc2_ = int(_loc3_.overwriteProps.length);
  390.                      while(--_loc2_ > -1)
  391.                      {
  392.                         this.propTweenLookup[_loc3_.overwriteProps[_loc2_]] = this.cachedPT1;
  393.                      }
  394.                   }
  395.                   else
  396.                   {
  397.                      this.propTweenLookup[this.cachedPT1.name] = this.cachedPT1;
  398.                   }
  399.                   if(_loc3_.priority)
  400.                   {
  401.                      this.cachedPT1.priority = _loc3_.priority;
  402.                      _loc4_ = true;
  403.                   }
  404.                   if(Boolean(_loc3_.onDisable) || Boolean(_loc3_.onEnable))
  405.                   {
  406.                      _notifyPluginsOfEnabled = true;
  407.                   }
  408.                   _hasPlugins = true;
  409.                }
  410.                else
  411.                {
  412.                   this.cachedPT1 = new PropTween(this.target,_loc1_,Number(this.target[_loc1_]),typeof this.vars[_loc1_] == "number" ? Number(this.vars[_loc1_]) - this.target[_loc1_] : Number(this.vars[_loc1_]),_loc1_,false,this.cachedPT1);
  413.                   this.propTweenLookup[_loc1_] = this.cachedPT1;
  414.                }
  415.             }
  416.          }
  417.          if(_loc4_)
  418.          {
  419.             onPluginEvent("onInit",this);
  420.          }
  421.          if(this.vars.runBackwards)
  422.          {
  423.             _loc6_ = this.cachedPT1;
  424.             while(_loc6_)
  425.             {
  426.                _loc6_.start += _loc6_.change;
  427.                _loc6_.change = -_loc6_.change;
  428.                _loc6_ = _loc6_.nextNode;
  429.             }
  430.          }
  431.          _hasUpdate = Boolean(this.vars.onUpdate != null);
  432.          if(_overwrittenProps)
  433.          {
  434.             killVars(_overwrittenProps);
  435.             if(this.cachedPT1 == null)
  436.             {
  437.                this.setEnabled(false,false);
  438.             }
  439.          }
  440.          if(_overwrite > 1 && this.cachedPT1 && (_loc5_ = masterList[this.target]) && _loc5_.length > 1)
  441.          {
  442.             if(overwriteManager.manageOverwrites(this,this.propTweenLookup,_loc5_,_overwrite))
  443.             {
  444.                init();
  445.             }
  446.          }
  447.          this.initted = true;
  448.       }
  449.       
  450.       public function killVars(param1:Object, param2:Boolean = true) : Boolean
  451.       {
  452.          var _loc3_:String = null;
  453.          var _loc4_:PropTween = null;
  454.          var _loc5_:Boolean = false;
  455.          if(_overwrittenProps == null)
  456.          {
  457.             _overwrittenProps = {};
  458.          }
  459.          for(_loc3_ in param1)
  460.          {
  461.             if(_loc3_ in propTweenLookup)
  462.             {
  463.                _loc4_ = propTweenLookup[_loc3_];
  464.                if(_loc4_.isPlugin && _loc4_.name == "_MULTIPLE_")
  465.                {
  466.                   _loc4_.target.killProps(param1);
  467.                   if(_loc4_.target.overwriteProps.length == 0)
  468.                   {
  469.                      _loc4_.name = "";
  470.                   }
  471.                }
  472.                if(_loc4_.name != "_MULTIPLE_")
  473.                {
  474.                   if(_loc4_.nextNode)
  475.                   {
  476.                      _loc4_.nextNode.prevNode = _loc4_.prevNode;
  477.                   }
  478.                   if(_loc4_.prevNode)
  479.                   {
  480.                      _loc4_.prevNode.nextNode = _loc4_.nextNode;
  481.                   }
  482.                   else if(this.cachedPT1 == _loc4_)
  483.                   {
  484.                      this.cachedPT1 = _loc4_.nextNode;
  485.                   }
  486.                   if(_loc4_.isPlugin && Boolean(_loc4_.target.onDisable))
  487.                   {
  488.                      _loc4_.target.onDisable();
  489.                      if(_loc4_.target.activeDisable)
  490.                      {
  491.                         _loc5_ = true;
  492.                      }
  493.                   }
  494.                   delete propTweenLookup[_loc3_];
  495.                }
  496.             }
  497.             if(param2 && param1 != _overwrittenProps)
  498.             {
  499.                _overwrittenProps[_loc3_] = 1;
  500.             }
  501.          }
  502.          return _loc5_;
  503.       }
  504.       
  505.       override public function invalidate() : void
  506.       {
  507.          if(_notifyPluginsOfEnabled && Boolean(this.cachedPT1))
  508.          {
  509.             onPluginEvent("onDisable",this);
  510.          }
  511.          this.cachedPT1 = null;
  512.          _overwrittenProps = null;
  513.          _hasUpdate = this.initted = this.active = _notifyPluginsOfEnabled = false;
  514.          this.propTweenLookup = {};
  515.       }
  516.    }
  517. }
  518.  
  519.