`

一个特效(页面过渡)

    博客分类:
  • AIR
阅读更多

login.mxml部分:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="800" height="600" verticalScrollPolicy="off" horizontalScrollPolicy="off" creationComplete="init();">
  <mx:Script>
   <![CDATA[
    import mx.core.UIComponent;
    import gs.TweenLite;
    import mx.controls.Alert;
   
      
       private var loginForm:LoginForm;
       private var mainForm:MainForm;;
       private function init():void
       {
         loginForm=new LoginForm();
         loginForm.x=0;
         loginForm.y=0;
         TweenLite.to(loginForm, 3, {alpha:1, x:440, y:220, delay:0.5});
         addChild(loginForm);
        
         loginForm.addEventListener("dengluEvent",onlogin);
         loginForm.resetbt.addEventListener(MouseEvent.CLICK,onreset);
       }
       private function onlogin(evt:Event):void
       {
         if(loginForm.username.text==""||loginForm.password.text=="")
         {
           Alert.show("用户名/密码不能为空");
         }else{
           TweenLite.to(loginForm.loginform, 2, {alpha : 0, onComplete :onDisplay});
         }
       }
       private function onDisplay():void
       {
          TweenLite.to(loginForm, 2, {width :10, height :600, onComplete :enterFrame});
       }
       private function enterFrame():void
       {
          mainForm=new MainForm();
          mainForm.width=10;
          this.removeAllChildren();
          this.addChild(mainForm);
          TweenLite.to(mainForm, 2, {width : 800, onComplete : addChilda});
         
       }
       private function addChilda():void
       {
      
       }
       private function onreset(evt:Event):void
       {
         loginForm.username.text="";
         loginForm.password.text="";
       }
   ]]>
  </mx:Script>
</mx:WindowedApplication>


LoginForm.mxml部分:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" isPopUp="true" width="400" height="300" fontSize="12" verticalCenter="0"  horizontalCenter="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
 <mx:Form width="100%" height="100%" id="loginform"> 
  <mx:FormItem label="用户名:">
   <mx:TextInput id="username"/>
  </mx:FormItem>
  <mx:FormItem label="密码:">
   <mx:TextInput id="password" displayAsPassword="true"/>
  </mx:FormItem>
  <mx:FormItem direction="horizontal">
   <mx:Button id = "loginbt" label="登陆" click="dispatchEvent(new Event('dengluEvent'))"/>
   <mx:Button id = "resetbt" label="重写"/>
  </mx:FormItem>
 </mx:Form>
</mx:Panel>

MainForm.mxml部分:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" isPopUp="true" width="400" height="300" fontSize="12" verticalCenter="0"  horizontalCenter="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
 <mx:Form width="100%" height="100%" id="loginform"> 
  <mx:FormItem label="用户名:">
   <mx:TextInput id="username"/>
  </mx:FormItem>
  <mx:FormItem label="密码:">
   <mx:TextInput id="password" displayAsPassword="true"/>
  </mx:FormItem>
  <mx:FormItem direction="horizontal">
   <mx:Button id = "loginbt" label="登陆" click="dispatchEvent(new Event('dengluEvent'))"/>
   <mx:Button id = "resetbt" label="重写"/>
  </mx:FormItem>
 </mx:Form>
</mx:Panel>

需要用到的TweenLite类:

 

/*
VERSION: 10.092
DATE: 3/31/2009
ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available)
UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenLite.com
DESCRIPTION:
 TweenLite is an extremely lightweight, FAST, and flexible tweening engine that serves as the core of
 the GreenSock tweening platform. There are plenty of other tweening engines out there to choose from,
 so here's why you might want to consider TweenLite:
 
  - SPEED - I'm not aware of any popular tweening engine with a similar feature set that's as fast
    as TweenLite. See some speed comparisons yourself at http://blog.greensock.com/tweening-speed-test/
   
  - Feature set - In addition to tweening ANY numeric property of ANY object, TweenLite can tween filters,
    hex colors, volume, tint, and frames, and even do bezier tweening, plus LOTS more. TweenMax extends
    TweenLite and adds even more capabilities like pause/resume, rounding, event listeners, and more.
    Overwrite management is an important consideration for a tweening engine as well which is another
    area where the GreenSock tweening platform shines. You have options for AUTO overwriting or you can
    manually define how each tween will handle overlapping tweens of the same object.
   
  - Expandability - With its new plugin architecture, you can activate as many (or as few) features as your
    project requires. Or write your own plugin if you need a feature that's unavailable. Minimize bloat, and
    maximize performance.
   
  - Management features - TweenGroup makes it surprisingly simple to create complex sequences and groups
    of TweenLite/Max tweens that you can pause(), resume(), restart(), or reverse(). You can even tween a TweenGroup's
    progress property to fastforward or rewind the entire group/sequence.
   
  - Ease of use - Designers and Developers alike rave about how intuitive the GreenSock tweening platform is.
  
  - Updates - Frequent updates and feature additions make the GreenSock tweening platform reliable and robust.
  
  - AS2 and AS3 - Most other engines are only developed for AS2 or AS3 but not both.
 

PARAMETERS:
 1) $target : Object - Target object whose properties we're tweening
 2) $duration : Number - Duration (in seconds) of the tween
 3) $vars : Object - An object containing the end values of all the properties you'd like tweened (or if you're using
             TweenLite.from(), these variables would define the BEGINNING values). For example, to tween
             myClip's alpha to 0.5 over the course of 1 second, you'd do: TweenLite.to(myClip, 1, {alpha:0.5}).
             
SPECIAL PROPERTIES (no plugins required):
 Any of the following special properties can optionally be passed in through the $vars object (the third parameter):

 delay : Number - Amount of delay before the tween should begin (in seconds).
 
 ease : Function - Use any standard easing equation to control the rate of change. For example,
       gs.easing.Elastic.easeOut. The Default is Regular.easeOut.
 
 easeParams : Array - An Array of extra parameters to feed the easing equation. This can be useful when
       using an ease like Elastic and want to control extra parameters like the amplitude and period.
       Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams.
 
 onStart : Function - If you'd like to call a function as soon as the tween begins, reference it here.
 
 onStartParams : Array - An Array of parameters to pass the onStart function.
 
 onUpdate : Function - If you'd like to call a function every time the property values are updated (on every frame during
        the course of the tween), reference it here.
 
 onUpdateParams : Array - An Array of parameters to pass the onUpdate function
 
 onComplete : Function - If you'd like to call a function when the tween has finished, reference it here.
 
 onCompleteParams : Array - An Array of parameters to pass the onComplete function
 
 persist : Boolean - if true, the TweenLite instance will NOT automatically be removed by the garbage collector when it is complete.
           However, it is still eligible to be overwritten by new tweens even if persist is true. By default, it is false.
 
 renderOnStart : Boolean - If you're using TweenLite.from() with a delay and want to prevent the tween from rendering until it
         actually begins, set this to true. By default, it's false which causes TweenLite.from() to render
         its values immediately, even before the delay has expired.
 
 overwrite : int - Controls how other tweens of the same object are handled when this tween is created. Here are the options:
       - 0 (NONE): No tweens are overwritten. This is the fastest mode, but you need to be careful not to create any
          tweens with overlapping properties, otherwise they'll conflict with each other.
        
     - 1 (ALL): (this is the default unless OverwriteManager.init() has been called) All tweens of the same object
          are completely overwritten immediately when the tween is created.
            TweenLite.to(mc, 1, {x:100, y:200});
         TweenLite.to(mc, 1, {x:300, delay:2, overwrite:1}); //immediately overwrites the previous tween
         
     - 2 (AUTO): (used by default if OverwriteManager.init() has been called) Searches for and overwrites only
        individual overlapping properties in tweens that are active when the tween begins.
         TweenLite.to(mc, 1, {x:100, y:200});
         TweenLite.to(mc, 1, {x:300, overwrite:2}); //only overwrites the "x" property in the previous tween
         
     - 3 (CONCURRENT): Overwrites all tweens of the same object that are active when the tween begins.
           TweenLite.to(mc, 1, {x:100, y:200});
           TweenLite.to(mc, 1, {x:300, delay:2, overwrite:3}); //does NOT overwrite the previous tween because the first tween will have finished by the time this one begins.
 

PLUGINS:
 There are many plugins that add capabilities through other special properties. Some examples are "tint",
 "volume", "frame", "frameLabel", "bezier", "blurFilter", "colorMatrixFilter", "hexColors", and many more.
 Adding the capabilities is as simple as activating the plugin with a single line of code, like TintPlugin.activate();
 Get information about all the plugins at http://blog.greensock.com/plugins/


EXAMPLES:
 Tween the alpha to 50% (0.5) and move the x position of a MovieClip named "clip_mc"
 to 120 and fade the volume to 0 over the course of 1.5 seconds like so:
 
  import gs.*;
  TweenLite.to(clip_mc, 1.5, {alpha:0.5, x:120, volume:0});
 
 If you want to get more advanced and tween the clip_mc MovieClip over 5 seconds, changing the alpha to 0.5,
 the x to 120 using the "Back.easeOut" easing function, delay starting the whole tween by 2 seconds, and then call
 a function named "onFinishTween" when it has completed and pass a few parameters to that function (a value of
 5 and a reference to the clip_mc), you'd do so like:
  
  import gs.*;
  import gs.easing.*;
  TweenLite.to(clip_mc, 5, {alpha:0.5, x:120, ease:Back.easeOut, delay:2, onComplete:onFinishTween, onCompleteParams:[5, clip_mc]});
  function onFinishTween(argument1:Number, argument2:MovieClip):void {
   trace("The tween has finished! argument1 = " + argument1 + ", and argument2 = " + argument2);
  }
 
 If you have a MovieClip on the stage that is already in it's end position and you just want to animate it into
 place over 5 seconds (drop it into place by changing its y property to 100 pixels higher on the screen and
 dropping it from there), you could:
  
  import gs.*;
  import gs.easing.*;
  TweenLite.from(clip_mc, 5, {y:"-100", ease:Elastic.easeOut});  
 

NOTES:

 - The base TweenLite class adds about 2.9kb to your Flash file, but if you activate the extra features
   that were available in versions prior to 10.0 (tint, removeTint, frame, endArray, visible, and autoAlpha),
   it totals about 5k. You can easily activate those plugins by uncommenting out the associated lines of
   code in the constructor.
  
 - Passing values as Strings will make the tween relative to the current value. For example, if you do
   TweenLite.to(mc, 2, {x:"-20"}); it'll move the mc.x to the left 20 pixels which is the same as doing
   TweenLite.to(mc, 2, {x:mc.x - 20}); You could also cast it like: TweenLite.to(mc, 2, {x:String(myVariable)});
  
 - You can change the TweenLite.defaultEase function if you prefer something other than Regular.easeOut.
 
 - Kill all tweens for a particular object anytime with the TweenLite.killTweensOf(myClip_mc);
   function. If you want to have the tweens forced to completion, pass true as the second parameter,
   like TweenLite.killTweensOf(myClip_mc, true);
  
 - You can kill all delayedCalls to a particular function using TweenLite.killDelayedCallsTo(myFunction_func);
   This can be helpful if you want to preempt a call.
  
 - Use the TweenLite.from() method to animate things into place. For example, if you have things set up on
   the stage in the spot where they should end up, and you just want to animate them into place, you can
   pass in the beginning x and/or y and/or alpha (or whatever properties you want).
  
 - If you find this class useful, please consider joining Club GreenSock which not only contributes
   to ongoing development, but also gets you bonus classes (and other benefits) that are ONLY available
   to members. Learn more at http://blog.greensock.com/club/
  
  
CHANGE LOG:

 10.091:
  - Fixed bug that prevented timeScale tweens of TweenGroups
 10.09:
  - Fixed bug with timeScale
 10.06:
  - Speed improvements
  - Integrated a new gs.utils.tween.TweenInfo class
  - Minor internal changes
 10.0:
  - Major update, shifting to a "plugin" architecture for handling special properties.
  - Added "remove" property to all filter tweens to accommodate removing the filter at the end of the tween
  - Added "setSize" and "frameLabel" plugins
  - Speed enhancements
  - Fixed minor overwrite bugs
 9.3:
  - Added compatibility with TweenProxy and TweenProxy3D
 9.291:
  - Adjusted how the timeScale special property is handled internally. It should be more flexible and slightly faster now.
 9.29:
  - Minor speed enhancement
 9.26:
  - Speed improvement and slight file size decrease
 9.25:
  - Fixed bug with autoAlpha tweens working with TweenGroups when they're reversed.
 9.22:
  - Fixed bug with from() when used in a TweenGroup
 9.12:
  - Fixed but with TweenLiteVars, TweenFilterVars, and TweenMaxVars that caused "visible" to always get set at the end of a tween
 9.1:
  - In AUTO or CONCURRENT mode, OverwriteManager doesn't handle overwriting until the tween actually begins which allows for immediate pause()-ing or re-ordering in TweenGroup, etc.
  - Re-architected some inner-workings to further optimize for speed and reduce file size
 9.05:
  - Fixed bug with killTweensOf()
  - Fixed bug with from()
  - Fixed bug with timeScale
 9.0:
  - Made compatible with the new TweenGroup class (see http://blog.greensock.com/tweengroup/ for details) which allows for sequencing and much more
  - Added clear() method
  - Added a "clear" parameter to the removeTween() method
  - Exposed TweenLite.currentTime as well as several other variables for compatibility with TweenGroup
 8.16:
  - Fixed bug that prevented using another tween to gradually change the timeScale of a tween
 8.15:
  - Fixed bug that caused from() delays not to function since version 8.14
 8.14:
  - Fixed bug in managing overwrites
 8.11:
  - Added the ability to overwrite only individual overlapping properties with the new OverwriteManager class
  - Added the killVars() method
  - Fixed potential garbage collection issue
 7.04:
  - Speed optimizations
 7.02:
  - Added ability to tween the volume of any object that has a soundTransform property instead of just MoveiClips and SoundChannels. Now NetStream volumes can be tweened too.
 7.01:
  - Fixed delayedCall() error (removed onCompleteScope since it's not useful in AS3 anyway)
 7.0:
  - Added "persist" special property
  - Added "removeTint" special property (please use this instead of tint:null)
  - Added compatibility with TweenLiteVars utility class

AUTHOR: Jack Doyle, jack@greensock.com
Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
*/

package gs {
 import flash.display.*;
 import flash.events.*;
 import flash.utils.*;
 
 import gs.plugins.*;
 import gs.utils.tween.*;

 public class TweenLite {
  public static const version:Number = 10.092;
  public static var plugins:Object = {};
  public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
  public static var defaultEase:Function = TweenLite.easeOut;
  public static var overwriteManager:Object; //makes it possible to integrate the gs.utils.tween.OverwriteManager for adding autoOverwrite capabilities
  public static var currentTime:uint;
  public static var masterList:Dictionary = new Dictionary(false); //Holds references to all our instances.
  public static var timingSprite:Sprite = new Sprite(); //A reference to the sprite that we use to drive all our ENTER_FRAME events.
  private static var _tlInitted:Boolean; //TweenLite class initted
  private static var _timer:Timer = new Timer(2000);
  protected static var _reservedProps:Object = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, runBackwards:1, startAt:1, onUpdate:1, onUpdateParams:1, roundProps:1, onStart:1, onStartParams:1, persist:1, renderOnStart:1, proxiedEase:1, easeParams:1, yoyo:1, loop:1, onCompleteListener:1, onUpdateListener:1, onStartListener:1, orientToBezier:1, timeScale:1};
 
  public var duration:Number; //Duration (in seconds)
  public var vars:Object; //Variables (holds things like alpha or y or whatever we're tweening)
  public var delay:Number; //Delay (in seconds)
  public var startTime:Number; //Start time
  public var initTime:Number; //Time of initialization. Remember, we can build in delays so this property tells us when the frame action was born, not when it actually started doing anything.
  public var tweens:Array; //Contains parsed data for each property that's being tweened (target, property, start, change, name, and isPlugin).
  public var target:Object; //Target object
  public var active:Boolean;
  public var ease:Function;
  public var initted:Boolean;
  public var combinedTimeScale:Number; //even though TweenLite doesn't use this variable TweenMax does and it optimized things to store it here, particularly for TweenGroup
  public var gc:Boolean; //flagged for garbage collection
  public var started:Boolean;
  public var exposedVars:Object; //Helps when using TweenLiteVars and TweenMaxVars utility classes because certain properties are only exposed via vars.exposedVars (for example, the "visible" property is Boolean, so we cannot normally check to see if it's undefined)
  
  protected var _hasPlugins:Boolean; //if there are TweenPlugins in the tweens Array, we set this to true - it helps speed things up in onComplete
  protected var _hasUpdate:Boolean; //has onUpdate. Tracking this as a Boolean value is faster than checking this.vars.onUpdate == null.
  
  public function TweenLite($target:Object, $duration:Number, $vars:Object) {
   if ($target == null) {
    return
   }
   if (!_tlInitted) {
    
    TweenPlugin.activate([
  
  
     //ACTIVATE (OR DEACTIVATE) PLUGINS HERE...
     
     TintPlugin,     //tweens tints
     RemoveTintPlugin,   //allows you to remove a tint
     FramePlugin,    //tweens MovieClip frames
     AutoAlphaPlugin,   //tweens alpha and then toggles "visible" to false if/when alpha is zero
     VisiblePlugin,    //tweens a target's "visible" property
     VolumePlugin,    //tweens the volume of a MovieClip or SoundChannel or anything with a "soundTransform" property
     EndArrayPlugin    //tweens numbers in an Array  
     
     
     ]);
    
    
    currentTime = getTimer();
    timingSprite.addEventListener(Event.ENTER_FRAME, updateAll, false, 0, true);
    if (overwriteManager == null) {
     overwriteManager = {mode:1, enabled:false};
    }   
    _timer.addEventListener("timer", killGarbage, false, 0, true);
             _timer.start();
    _tlInitted = true;
   }
   this.vars = $vars;
   this.duration = $duration || 0.001; //easing equations don't work when the duration is zero.
   this.delay = $vars.delay || 0;
   this.combinedTimeScale = $vars.timeScale || 1;
   this.active = Boolean($duration == 0 && this.delay == 0);
   this.target = $target;
   if (typeof(this.vars.ease) != "function") {
    this.vars.ease = defaultEase;
   }
   if (this.vars.easeParams != null) {
    this.vars.proxiedEase = this.vars.ease;
    this.vars.ease = easeProxy;
   }
   this.ease = this.vars.ease;
   this.exposedVars = (this.vars.isTV == true) ? this.vars.exposedVars : this.vars; //for TweenLiteVars and TweenMaxVars (we need an object with enumerable properties)
   this.tweens = [];
   this.initTime = currentTime;
   this.startTime = this.initTime + (this.delay * 1000);
   
   var mode:int = ($vars.overwrite == undefined || (!overwriteManager.enabled && $vars.overwrite > 1)) ? overwriteManager.mode : int($vars.overwrite);
   if (!($target in masterList) || mode == 1) {
    masterList[$target] = [this];
   } else {
    masterList[$target].push(this);
   }
   
   if ((this.vars.runBackwards == true && this.vars.renderOnStart != true) || this.active) {
    initTweenVals();
    if (this.active) { //Means duration is zero and delay is zero, so render it now, but add one to the startTime because this.duration is always forced to be at least 0.001 since easing equations can't handle zero.
     render(this.startTime + 1);
    } else {
     render(this.startTime);
    }
    if (this.exposedVars.visible != null && this.vars.runBackwards == true && (this.target is DisplayObject)) {
     this.target.visible = this.exposedVars.visible;
    }
   }
  }
  
  public function initTweenVals():void {
   var p:String, i:int, plugin:*;
   if (this.exposedVars.timeScale != undefined && this.target.hasOwnProperty("timeScale")) {
    this.tweens[this.tweens.length] = new TweenInfo(this.target, "timeScale", this.target.timeScale, this.exposedVars.timeScale - this.target.timeScale, "timeScale", false); //[object, property, start, change, name, isPlugin]
   }
   for (p in this.exposedVars) {
    if (p in _reservedProps) {
     //ignore
     
    } else if (p in plugins) {
     plugin = new plugins[p]();
     if (plugin.onInitTween(this.target, this.exposedVars[p], this) == false) {
      this.tweens[this.tweens.length] = new TweenInfo(this.target, p, this.target[p], (typeof(this.exposedVars[p]) == "number") ? this.exposedVars[p] - this.target[p] : Number(this.exposedVars[p]), p, false); //[object, property, start, change, name, isPlugin]
     } else {
      this.tweens[this.tweens.length] = new TweenInfo(plugin, "changeFactor", 0, 1, (plugin.overwriteProps.length == 1) ? plugin.overwriteProps[0] : "_MULTIPLE_", true); //[object, property, start, change, name, isPlugin]
      _hasPlugins = true;
     }
     
    } else {
     this.tweens[this.tweens.length] = new TweenInfo(this.target, p, this.target[p], (typeof(this.exposedVars[p]) == "number") ? this.exposedVars[p] - this.target[p] : Number(this.exposedVars[p]), p, false); //[object, property, start, change, name, isPlugin]
    }
   }
   if (this.vars.runBackwards == true) {
    var ti:TweenInfo;
    for (i = this.tweens.length - 1; i > -1; i--) {
     ti = this.tweens[i];
     ti.start += ti.change;
     ti.change = -ti.change;
    }
   }
   if (this.vars.onUpdate != null) {
    _hasUpdate = true;
   }
   if (TweenLite.overwriteManager.enabled && this.target in masterList) {
    overwriteManager.manageOverwrites(this, masterList[this.target]);
   }
   this.initted = true;
  }
  
  public function activate():void {
   this.started = this.active = true;
   if (!this.initted) {
    initTweenVals();
   }
   if (this.vars.onStart != null) {
    this.vars.onStart.apply(null, this.vars.onStartParams);
   }
   if (this.duration == 0.001) { //In the constructor, if the duration is zero, we shift it to 0.001 because the easing functions won't work otherwise. We need to offset the this.startTime to compensate too.
    this.startTime -= 1;
   }
  }
  
  public function render($t:uint):void {
   var time:Number = ($t - this.startTime) * 0.001, factor:Number, ti:TweenInfo, i:int;
   if (time >= this.duration) {
    time = this.duration;
    factor = (this.ease == this.vars.ease || this.duration == 0.001) ? 1 : 0; //to accommodate TweenMax.reverse(). Without this, the last frame would render incorrectly
   } else {
    factor = this.ease(time, 0, 1, this.duration);   
   }
   for (i = this.tweens.length - 1; i > -1; i--) {
    ti = this.tweens[i];
    ti.target[ti.property] = ti.start + (factor * ti.change);
   }
   if (_hasUpdate) {
    this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
   }
   if (time == this.duration) {
    complete(true);
   }
  }
  
  public function complete($skipRender:Boolean = false):void {
   if (!$skipRender) {
    if (!this.initted) {
     initTweenVals();
    }
    this.startTime = currentTime - (this.duration * 1000) / this.combinedTimeScale;
    render(currentTime); //Just to force the final render
    return;
   }
   if (_hasPlugins) {
    for (var i:int = this.tweens.length - 1; i > -1; i--) {
     if (this.tweens[i].isPlugin && this.tweens[i].target.onComplete != null) { //function calls are expensive performance-wise, so don't call the plugin's onComplete() unless necessary. Most plugins don't require them.
      this.tweens[i].target.onComplete();
     }
    }
   }
   if (this.vars.persist != true) {
    this.enabled = false; //moved above the onComplete callback in case there's an error in the user's onComplete - this prevents constant errors
   }
   if (this.vars.onComplete != null) {
    this.vars.onComplete.apply(null, this.vars.onCompleteParams);
   }
  }
 
  public function clear():void {
   this.tweens = [];
   this.vars = this.exposedVars = {ease:this.vars.ease}; //just to avoid potential errors if someone tries to set the progress on a reversed tween that has been killed (unlikely, I know);
   _hasUpdate = false;
  }
  
  public function killVars($vars:Object):void {
   if (overwriteManager.enabled) {
    overwriteManager.killVars($vars, this.exposedVars, this.tweens);
   }
  }
  
  
//---- STATIC FUNCTIONS -------------------------------------------------------------------------
  
  public static function to($target:Object, $duration:Number, $vars:Object):TweenLite {
   return new TweenLite($target, $duration, $vars);
  }
  
  public static function from($target:Object, $duration:Number, $vars:Object):TweenLite {
   $vars.runBackwards = true;
   return new TweenLite($target, $duration, $vars);
  }
  
  public static function delayedCall($delay:Number, $onComplete:Function, $onCompleteParams:Array = null):TweenLite {
   return new TweenLite($onComplete, 0, {delay:$delay, onComplete:$onComplete, onCompleteParams:$onCompleteParams, overwrite:0});
  }
  
  public static function updateAll($e:Event = null):void {
   var time:uint = currentTime = getTimer(), ml:Dictionary = masterList, a:Array, i:int, tween:TweenLite;
   for each (a in ml) {
    for (i = a.length - 1; i > -1; i--) {
     tween = a[i];
     if (tween.active) {
      tween.render(time);
     } else if (tween.gc) {
      a.splice(i, 1);
     } else if (time >= tween.startTime) {
      tween.activate();
      tween.render(time);
     }
    }
   }
  }
  
  public static function removeTween($tween:TweenLite, $clear:Boolean = true):void {
   if ($tween != null) {
    if ($clear) {
     $tween.clear();
    }
    $tween.enabled = false;
   }
  }
  
  public static function killTweensOf($target:Object = null, $complete:Boolean = false):void {
   if ($target != null && $target in masterList) {
    var a:Array = masterList[$target], i:int, tween:TweenLite;
    for (i = a.length - 1; i > -1; i--) {
     tween = a[i];
     if ($complete && !tween.gc) {
      tween.complete(false);
     }
     tween.clear(); //prevents situations where a tween is killed but is still referenced elsewhere and put back in the render queue, like if a TweenLiteGroup is paused, then the tween is removed, then the group is unpaused.
    }
    delete masterList[$target];
   }
  }
  
  protected static function killGarbage($e:TimerEvent):void {
   var ml:Dictionary = masterList, tgt:Object;
   for (tgt in ml) {
    if (ml[tgt].length == 0) {
     delete ml[tgt];
    }
   }
  }
  
  public static function easeOut($t:Number, $b:Number, $c:Number, $d:Number):Number {
   return -$c * ($t /= $d) * ($t - 2) + $b;
  }
  
  
//---- PROXY FUNCTIONS ------------------------------------------------------------------------
  
  protected function easeProxy($t:Number, $b:Number, $c:Number, $d:Number):Number { //Just for when easeParams are passed in via the vars object.
   return this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams));
  }
  
  
//---- GETTERS / SETTERS -----------------------------------------------------------------------
  
  public function get enabled():Boolean {
   return (this.gc) ? false : true;
  }
  
  public function set enabled($b:Boolean):void {
   if ($b) {
    if (!(this.target in masterList)) {
     masterList[this.target] = [this];
    } else {
     var a:Array = masterList[this.target], found:Boolean, i:int;
     for (i = a.length - 1; i > -1; i--) {
      if (a[i] == this) {
       found = true;
       break;
      }
     }
     if (!found) {
      a[a.length] = this;
     }
    }
   }
   this.gc = ($b) ? false : true;
   if (this.gc) {
    this.active = false;
   } else {
    this.active = this.started;
   }
  }
 }
 
}

分享到:
评论

相关推荐

    4种纯CSS3超酷页面切换过渡动画特效

    这是一款4种效果非常炫酷的纯CSS3页面切换过渡动画特效。该CSS3页面过渡动画使用CSS keyframes制作而成,所有的动画效果和延时都是使用CSS属性,没有任何的javascript timeout()代码。

    实现页面平滑过渡特效

    通过 `transition` 属性,我们可以指定一个或多个CSS属性在两种状态之间过渡的时间、速度曲线、延迟等参数。例如: ```css .box { width: 100px; height: 100px; background-color: red; transition: width 0.5...

    winform 窗体过渡特效 源码

    首先,窗体过渡特效通常涉及到以下几个关键技术点: 1. **窗口动画API**:在.NET Framework中,虽然没有内置的窗体动画支持,但可以通过自定义代码和Windows API调用来实现。例如,可以使用`SetWindowPos`函数来...

    纯CSS3页面切换过渡动画

    首先,我们要理解CSS3中的关键帧动画(@keyframes)是实现页面过渡动画的基础。通过定义动画的开始和结束状态,以及中间的各个阶段,我们可以创建平滑的过渡效果。例如,一个简单的页面切换动画可能包括元素的淡入...

    jQuery和CSS3通过AJAX调用切换页面过渡动画特效

    **jQuery和CSS3结合AJAX实现的页面过渡动画特效** 在网页设计中,提供流畅的用户体验是至关重要的,其中一种方法就是使用页面过渡动画。这个技术允许用户在浏览不同页面时,享受到平滑且吸引人的视觉体验。"jQuery...

    html5 svg卷帘式变形拉开页面过渡动画特效

    在本案例中,我们讨论的是一个使用HTML5和SVG实现的卷帘式变形拉开页面过渡动画特效。这个特效能够为用户带来独特的浏览体验,使网站更加生动和引人入胜。以下是关于这个特效的详细知识点: 1. **HTML5 SVG**: SVG...

    jQuery实现切换页面过渡动画效果

    是一款效果非常酷的jQuery和CSS3通过AJAX调用切换页面过渡动画特效插件。该页面切换特效使用AJAX来动态加载链接内容,在页面加载的时候,使用CSS3来制作非常酷的页面过渡动画效果。插件中使用pushState方法来管理...

    100个Javascript特效页面以及源代码

    "100个Javascript特效页面以及源代码"集合涵盖了多种JavaScript技术的应用实例,是学习和研究JavaScript特效的理想资源。下面将详细介绍其中可能包含的一些关键知识点。 1. **DOM操作**:JavaScript通过Document ...

    barbajsJavaScript实现的平滑页面过渡特效

    `barba.js`是一个JavaScript库,专为实现平滑的页面过渡效果而设计,以此提升用户体验,减少页面加载时的延迟感。通过将页面分割成独立的“视区”(或称为“容器”),`barba.js`可以实现页面间的无缝切换,无需重新...

    制作网页特效页面

    网页特效页面制作是Web开发中的一个重要环节,它能够提升网站的互动性和用户体验。Dreamweaver作为Adobe公司出品的一款专业级的网页设计工具,是许多Web开发者首选的制作平台。本项目利用Dreamweaver来实现包括幻灯...

    html5 svg卷帘式变形拉开页面过渡动画特效.zip

    总的来说,这个压缩包提供了一个HTML5 SVG和jQuery结合的实例,展示了如何利用这两个技术来创建复杂的页面过渡动画。对于开发者来说,这是一个学习和实践SVG动画、jQuery插件开发的好素材,也可以根据自己的需求进行...

    页面载入缓冲效果,页面缓冲特效

    这就是页面缓冲特效的作用,它在内容实际加载之前提供了一个过渡,既让用户知道页面正在处理请求,又可以缓解用户对等待的焦虑感。 1. **页面载入**:页面载入是指浏览器接收服务器发送的HTML、CSS、JavaScript等...

    jQuery超炫平滑过渡垂直滚动视觉差特效

    jquery.parallax-scroll是一款效果超炫的平滑垂直滚动视觉差jQuery特效。该视觉差特效使用requestAnimationFrame和CSS3 3D transitions在页面垂直滚动时制作非常平滑的过渡动画效果。

    大量静态页面模板+牛逼的动态特效页面

    在IT行业中,特别是Web开发领域,静态页面模板和动态特效页面是两个重要的组成部分。静态页面模板主要用于快速构建网站的基础布局,而动态特效则为用户体验增添趣味性和互动性。以下是对这些资源的详细解读: 首先...

    Activity页面跳转特效

    在Android应用开发中,Activity页面跳转特效是一个增强用户体验的重要环节。通过巧妙地设计和实现这些特效,可以为用户带来更加生动和有趣的交互体验。在Android 5.0(Lollipop)及更高版本中,系统引入了Transition...

    wpf页面切换特效

    WPF提供了一套强大的图形渲染引擎和动画框架,使得开发者能够轻松实现各种复杂的页面过渡效果。本篇文章将深入探讨如何在WPF中创建页面切换特效。 首先,我们需要了解WPF中的页面导航系统。在WPF中,页面通常由`...

    IE自带的网页过渡特效

    ### IE自带的网页过渡特效详解 ...综上所述,虽然IE自带的网页过渡特效在当时具有较高的实用价值,但在当前Web开发环境下,开发者更倾向于使用更为灵活、兼容性更好的CSS3动画或第三方JavaScript库来实现页面过渡效果。

    wpf界面切换特效

    每个页面通常是一个单独的XAML文件,可以通过URI指定并加载。 2. **动画**:WPF内置了丰富的动画系统,包括补间动画(Interpolating Animation)、关键帧动画(Keyframe Animation)等,可用于在界面切换时添加过渡...

    web页面所有特效类

    图片特效类”,显然包含了一系列与Web页面图片特效相关的资料,旨在帮助学习者掌握这一领域的技能。以下是关于Web页面图片特效的一些关键知识点: 1. CSS3过渡(Transitions):CSS3过渡允许我们在元素的状态之间...

    javascript经典特效---打开页面特效(二).rar

    总的来说,"javascript经典特效---打开页面特效(二).rar"中的示例可能是上述技术的一个实际应用,通过分析和学习这个示例,可以深入理解JavaScript如何与HTML和CSS协同工作,创建出吸引人的页面打开效果。...

Global site tag (gtag.js) - Google Analytics