Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
A YoYo Scale Effect With The Tween Class  

Download

How to create this scale effect with the tween class

Actionscript

import mx.transitions.Tween;
import mx.transitions.easing.*;

var xScaleT:Tween = new Tween(my_mc, "_xscale", Elastic.easeOut, -100, 100, 3, true);

xScaleT.onMotionFinished = function() {
this.yoyo();
};


Note: Press the "refresh" button in the browser to play the animation again.


The tween transition class is imported.


import mx.transitions.Tween;

All the easing transitions are imported to the ........

import mx.transitions.easing.*;

A new tween is contructed named "xScale" and defined using the tween class syntax:
Tween (object name, property, ease class, ,,,).


var xScaleT:Tween = new Tween(my_mc, "_xscale", Strong.easeOut, 0, 100, 6, true);

A new function is created that listens for the tween "aScale" to end its motion. When this occurs the function is triggered.

xScaleT.onMotionFinished = function() {

The yoyo function is then called replaying the tween with reversed coordinates.

this.yoyo();

The net effect of this fu nction is to reinitiate the tween each time it finishes creating and endless looping animation that yoyos back and forth.



© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us