FEffects 0.1.0 for Haxe (Tween for Flash8, Flash9 and JS)

13.04.2008 6758 1

Flash :

Javascript :
Click here to see the sample
These 3 last samples are form this sigle file, Main.hx :

import feffects.Tween;
import feffects.easing.Quint;
import feffects.easing.Sine;
import feffects.easing.Back;
import feffects.easing.Bounce;
import feffects.easing.Circ;
import feffects.easing.Cubic;
import feffects.easing.Elastic;
import feffects.easing.Expo;
import feffects.easing.Linear;
import feffects.easing.Quad;
import feffects.easing.Quart;
#if flash9
    import flash.display.MovieClip;
#else flash
    import flash.MovieClip;
#else js
    import js.Dom;
#end
class Main
{
    #if flash
        static var arr    : Array<MovieClip>;
    #else js
        static var arr    : Array<HtmlDom>;
    #end
    
    static function update( e : Float, i : Int )
    {
        #if flash9
            arr[ i ].y = e;
        #else flash
            arr[ i ]._y = e;
        #else js
            arr[ i ].style.top = e + "px";
        #end
    }
    
    static function end( e : Float, i : Int )
    {
        //trace( "end " + i + " : " + e );
    }
    
    static function main()
    {
        arr = new Array();
        
        var effects = 
        [ 
            Quint.easeIn, Quint.easeOut, Quint.easeInOut,
            Sine.easeIn, Sine.easeOut, Sine.easeInOut,
            Back.easeIn, Back.easeOut, Back.easeInOut,
            Bounce.easeIn, Bounce.easeOut, Bounce.easeInOut,
            Circ.easeIn, Circ.easeOut, Circ.easeInOut,
            Cubic.easeIn, Cubic.easeOut, Cubic.easeInOut,
            Elastic.easeIn, Elastic.easeOut, Elastic.easeInOut,
            Expo.easeIn, Expo.easeOut, Expo.easeInOut,
            Linear.easeIn, Linear.easeOut, Linear.easeInOut, Linear.easeNone,
            Quad.easeIn, Quad.easeOut, Quad.easeInOut,
            Quart.easeIn, Quart.easeOut, Quart.easeInOut
        ];
        
        for ( i in 0...effects.length )
        {
            #if flash9
                var sprite = new MovieClip();
                sprite.x = i * 10 + 30;
                var gfx = sprite.graphics;
                gfx.beginFill( 0x000000, 1 );
                flash.Lib.current.addChild( sprite );
            #else flash
                var sprite = flash.Lib.current.createEmptyMovieClip( "sprite" + i, i );
                sprite._x = i * 10 + 30;
                var gfx = sprite;
                gfx.beginFill( 0x000000, 100 );
            #end
            #if flash
                gfx.lineTo( 10, 0 );
                gfx.lineTo( 10, 10 );
                gfx.lineTo( 0, 10 );
                gfx.lineTo( 0, 0 );
                gfx.endFill();
            #else js
                var sprite = js.Lib.document.createElement( "div" );
                js.Lib.document.body.appendChild( sprite );
                sprite.style.position = "absolute";
                sprite.style.backgroundColor = "#000000";
                sprite.style.padding = 5;
                sprite.style.left = i * 10 + 30 + "px";
            #end
            
            arr.push( sprite );
        }
        
        for ( i in 0...effects.length )
        {
            var t = new Tween( Main, 50, 150, 5000 );
            t.setEasing( effects.pop() );
            t.setTweenHandlers( function ( e ) update( e, i ), function ( e ) end( e, i ) );
            t.start();
        }
    }
}

You can download the FEffect package here or from haxelib, using:

haxelib install feffects

Commentaires

01.09.2008 à 16:25 Ron

Nice piece of work! Thank you very much!

Laisser un commentaire

http://
×