Tween
| Kind of class: | class |
|---|---|
| Inherits from: | EventDispatcher < CoreObject |
| Implements: | |
| Known subclasses: | |
| Version: | 03/18/07 |
| Author: | Aaron Clinger, Mike Creighton |
| Classpath: | org.casaframework.transitions.Tween |
| File last modified: | Monday, 19 March 2007, 08:53:15 |
Simple and easily extendable tween class.
Advantages of using this tween class over others:
Advantages of using this tween class over others:
- Does not include any tweening equations, only the equation(s) a user defines. This allows for a much smaller class/swf file.
- Using built in events/event dispatcher you are able to tween more than one value.
- Ability to tween any value, not only MovieClip properties.
- Works with all easing equations that follow the currentTime, startPosition, endPosition, totalTime standard.
Example:
If you want to tween an item on a curve you can use the org.casaframework.math.geom.Ellipse class and its getPointOfDegree function:
var slideMotion:Tween = new Tween(com.robertpenner.easing.Bounce.easeOut, 0, 250, 1.5); this.slideMotion.addEventObserver(this, Tween.EVENT_POSITION, "onEasePosition"); this.slideMotion.start(); function onEasePosition(sender:Tween, position:Number):Void { this.box_mc._x = this.box_mc._y = position; }
If you want to tween an item on a curve you can use the org.casaframework.math.geom.Ellipse class and its getPointOfDegree function:
var curve:Ellipse = new Ellipse(20, 50, 300, 200); var slideMotion:Tween = new Tween(com.robertpenner.easing.Elastic.easeInOut, 0, 360, 4); this.slideMotion.addEventObserver(this, Tween.EVENT_POSITION, "onCurvePosition"); this.slideMotion.start(); function onCurvePosition(sender:Tween, degree:Number):Void { var position:Point = this.curve.getPointOfDegree(degree); this.box_mc._x = position.getX(); this.box_mc._y = position.getY(); }
Usage note:
If you want to tween a property use PropertyTween.
Events broadcast to listeners:
onStart = function (sender:Tween) {} onStop = function (sender:Tween) {} onResume = function (sender:Tween) {} onProgress = function (sender:Tween, progress:Percent) {} onPosition = function (sender:Tween, position:Number) {} onComplete = function (sender:Tween) {} Summary
Constructor
Instance properties
Instance properties inherited from EventDispatcher
Instance properties inherited from CoreObject
Instance methods
Instance methods inherited from EventDispatcher
Instance methods inherited from CoreObject
Constructor
Tween
function Tween (
equation:Function,
startPos:Number,
endPos:Number,
duration:Number,
useFrames:Boolean)
Creates and defines tween.
Parameters:
equation :
Tween equation.
startPos :
The starting value of the tween.
endPos :
The ending value of the tween.
duration :
Length of time of the tween.
useFrames:
[optional] Indicates to use frames
true, or seconds false in relation to the value specified in the duration parameter; defaults to false.Usage note:
The function specified in the
equation parameter must follow the (currentTime, startPosition, endPosition, totalTime) parameter standard.See also:
Class properties
EVENT_COMPLETE
static EVENT_COMPLETE:String = 'onComplete'
(read,write)
EVENT_POSITION
static EVENT_POSITION:String = 'onPosition'
(read,write)
EVENT_PROGRESS
static EVENT_PROGRESS:String = 'onProgress'
(read,write)
EVENT_RESUME
static EVENT_RESUME:String = 'onResume'
(read,write)
EVENT_START
static EVENT_START:String = 'onStart'
(read,write)
EVENT_STOP
static EVENT_STOP:String = 'onStop'
(read,write)
Instance methods
continueTo
function continueTo (
endPos:Number,
duration:Number) : Void
Instructs to tween from its current position to a new finish and duration position.
Parameters:
endPos :
The ending value of the tween.
duration:
Length of time of the tween.
Usage note:
Will automatically start tween if currently stopped.
destroy
function destroy (
) : Void
Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.
Always call
#Always call
destroy() before deleting last object pointer.Specified by:
resume
function resume (
) : Void
Resumes tween from stopped position.
Events broadcast to listeners:
onResume = function (sender:Tween) {} Specified by:
start
function start (
) : Void
Starts tween from start position.
Events broadcast to listeners:
onStart = function (sender:Tween) {} Specified by:
stop
function stop (
) : Void
Stops tween at current position.
Events broadcast to listeners:
onStop = function (sender:Tween) {} Specified by: