08 December 2013

Understanding the Tween class in Flash 8 ActionScript 2

The Tween class lets you move, resize, rotate, or fade a movieclip using only ActionScript. You can animate any property of a movieclip, such as x, y, rotation, scaleX, scaleY, and alpha. You can also specify how long the animation will last in either seconds or frames. 


The code will follow this example:

new mx.transitions.Tween (object, property, function, begin, end, duration, useSeconds)

example code :
new Tween( ball_mc , "_y" , Bounce.easeOut , ball_mc._y , 280 ,3 ,true ) ;

Flash now supports a shiny new class called Tween which allows for some quick and cool movie clip easing. The new class constructor looks like this:

someTweenID = new mx.transitions.Tween(object, property, function, begin, end, duration, useSeconds)

where:

object = reference name of the movie clip you wish to tween

property = a string value of the property you wish to tween

function = name of the easing class to use (more on this to come)

begin = number of above property you'd like to start with

end = number of above property you'd like to end with

duration = number frames or seconds the tween should last

useSeconds = boolean indicating whether the above duration is in frames (false) or seconds (true). If not included, the default is false

Easing options:


* Back – Causes the animation to overshoot, and return to its position.
* Bounce – Causes the animation to reverse direction, like a ball bouncing on a floor.
* Elastic – Causes the animation to overshoot and reverse, like at the end of a rubber band.
* Regular – Accelerates along a steady curve.
* Strong – Accelerates along a steady curve, more aggressive than Regular.
* None – Results in no acceleration; a steady speed.

Easing Functions:


* easeIn – The ease is applied to the beginning of the tween.
* easeInOut – The ease is applied to bothe the beginning and the end of the tween.
* easeOut – The ease is applied to the end of the tween.

Example: Bounce.easeOut , Elastic.easeIn , Strong.easeInOut etc....

Source:


(If you found this article useful then share with your friends.)

No comments: