LTweenLite Class
LTweenLite is an extremely fast, lightweight, and flexible animation tool that serves as the foundation Animation Platform.
Constructor
LTweenLite
()
public
Item Index
Methods
- LTweenLite.remove static
- LTweenLite.removeAll static
- LTweenLite.to static
Methods
LTweenLite.remove
-
tween
Static method to stop a tween affect.
Parameters:
-
tween
LTweenLiteChilda tween affect.
Example:
LInit(1000/50,"legend",800,450,main);
var tween;
function main(){
LGlobal.setDebug(true);
var rect = new LSprite();
rect.x = 50;
rect.y = 50;
rect.graphics.drawRect("#FF00FF",1,[0,0,20,20],true,"#FF00FF");
addChild(rect);
tween = LTweenLite.to(rect,1,{x:500,loop:true,ease:LEasing.Sine.easeInOut})
.to(rect,1,{x:50,ease:LEasing.Quad.easeInOut});
var stopButton = new LButtonSample1("stop");
stopButton.x = 50;
circle.y = 50;
stopButton.y = 100;
addChild(stopButton);
stopButton.addEventListener(LMouseEvent.MOUSE_UP,stopTween);
}
function stopTween(e){
LTweenLite.remove(tween);
}
LTweenLite.removeAll
()
public
static
Static method to stop all the tween affects.
Example:
LInit(1000/50,"legend",800,450,main);
var tween;
function main(){
LGlobal.setDebug(true);
var rect = new LSprite();
rect.x = 50;
rect.y = 50;
rect.graphics.drawRect("#FF00FF",1,[0,0,20,20],true,"#FF00FF");
addChild(rect);
tween = LTweenLite.to(rect,1,{x:500,loop:true,ease:LEasing.Sine.easeInOut})
.to(rect,1,{x:50,ease:LEasing.Quad.easeInOut});
var stopButton = new LButtonSample1("stop");
stopButton.x = 50;
circle.y = 50;
stopButton.y = 100;
addChild(stopButton);
stopButton.addEventListener(LMouseEvent.MOUSE_UP,stopTween);
}
function stopTween(e){
LTweenLite.remove(tween);
}
LTweenLite.to
-
target
-
duration
-
vars
Static method for creating a LTweenLiteChild instance that animates to the specified destination values (from the current values).
Parameters:
-
target
ObjectTarget object (or array of objects) whose properties this tween affects.
-
duration
FloatDuration in seconds (or frames if useFrames:true is set in the vars parameter).
-
vars
ObjectAn object defining the end value for each property that should be tweened as well as any special properties like onComplete, ease, etc. For example, to tween mc.x to 100 and mc.y to 200 and then call myFunction, do this: TweenLite.to(mc, 1, {x:100, y:200, onComplete:myFunction});
Typically the vars parameter is used to define ending values for tweening properties of the target like {x:100, y:200, alpha:0}, but the following optional special properties serve other purposes:
Property Type Explanation delay float Amount of delay in seconds (or frames for frames-based tweens) before the tween should begin. ease LEasing LEasing (or Function) - You can choose from various eases to control the rate of change during the animation, giving it a specific "feel". For example, LEasing.Quad.easeIn or LEasing.Cubic.easeOut. For best performance, use one of the eases. The default is LEasing.None.easeIn. onComplete Function A function that should be called when the tween has completed onStart Function A function that should be called when the tween begins (when its time changes from 0 to some other value which can happen more than once if the tween is restarted multiple times). onUpdate Function A function that should be called every time the tween updates (on every frame while the tween is active) loop Boolean If true, the tween will loop when it reaches the end. Can be set via the props param.
Returns:
LTweenLiteChild instance
Example:
LInit(1000/50,"legend",800,450,main);
function main(){
LGlobal.setDebug(true);
var circle = new LSprite();
circle.x = 50;
circle.y = 50;
circle.graphics.drawArc("#FF0000",1,[0,0,20,0,Math.PI*2],true,"#FF0000");
addChild(circle);
var rect = new LSprite();
rect.x = 50;
rect.y = 100;
rect.graphics.drawRect("#FF00FF",1,[0,0,20,20],true,"#FF00FF");
addChild(rect);
LTweenLite.to(circle,2,{x:500,y:400,scaleX:3,scaleY:3,ease:LEasing.Strong.easeInOut})
.to(circle,2,{x:700,y:50,scaleX:1,scaleY:1,ease:LEasing.Quint.easeIn,onComplete:function(e){
trace(e.currentTarget);
trace(e.target);
}});
LTweenLite.to(rect,1,{x:500,loop:true,ease:LEasing.Sine.easeInOut})
.to(rect,1,{x:50,ease:LEasing.Quad.easeInOut});
}