FEffects

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.

[feffects-chips.swf]

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).

Example


Sample.hx :
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();
    }
}

Then, in order to compile this sample, here comes the build file : build.hxml
-swf9 sample.swf
-main Sample
-lib feffects

This sample shows a text field that falls from the top (0) to the bottom (280) of the scene. When falling, the text field displays the real intermediate value. The duration is set to 5000 ms.
The first argument when creating a new Tween represents the objects where the callback functions update and end can be found. Here the callback move belong to the class instance, so this is used.
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 examples


You can see more samples, flash<=8, flash9 or JavaScript here

version #4827, modified 2008-11-03 14:12:44 by ncannasse