FEffects

You are viewing an old version of this entry, click here to see latest version.

FEffects is a library that enables you to create visual transitions like motion-tweens for example.
The package actually offers tweens and Robert Penners' easings are used here.
It can be used the same way, in your flash, flash9 and JavaScript projects.

Install


In order to use FEffects, you need to install the library using haxelib, like that :
haxelib install feffects

Then you can use the library by adding -lib feffects to haxe commandline parameters.

Tutorial


FEffects is used especially to create visual transitions, but in fact, it's just a numerical value interpolation: The Tween class will compute the intermediate values according to the begin value, the end value the duration and the choosen easing function.
You don't need to specify the property on which the interpolation will be applied. You just have to specify the callback function that will receive the computed value in argument. It's a float value, then you can do what you want with it and especially apply it for anything you want, any property (position, scale, rotation, alpha and more).
import feffects.Tween;
import feffects.easing.Bounce;

import flash.text.TextField;

class Sample
{
    var tf    : TextField;
    
    function new()
    {
        tf = new TextField();
        flash.Lib.current.addChild( tf );
        
        // creating the tween
        var tween = new Tween( this, 0, 280, 5000 );
        // setting the easing function 
        tween.setEasing( Bounce.easeOut );
        // setting the update function
        tween.setTweenHandlers( move );
        // launch the tween
        tween.start();
    }
    
    function move( e : Float )
    {
        tf.text = Std.string( e );
        tf.y = e;
    }
    
    static function main()
    {
        var v = new Sample();
    }
}

This sample shows a text field that falls from the top to the bottom of the scene. When falling, the text field displays the real intermediate value.
As you can see, a simple callback function is called move and we use the computed value, given in argument, to set the y position of the text field. But we also use this value to display it simply as text.

More samples


You can see more samples, flash<=8, flash9 or JavaScript here
version #3878, modified 2008-08-04 14:42:45 by filt3rek