In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Flat Preloader

Get Adobe Flash player
by WLAD 03 Oct 2015
/**
 * Copyright WLAD ( http://wonderfl.net/user/WLAD )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/q5wd
 */

package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        [SWF(frameRate="60", backgroundColor="#000000")]
        public function FlashTest() {
            
            graphics.beginFill(0);
            graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
            graphics.endFill();
            
            // write as3 code here..
            
            var p:PreloaderAnimation = new PreloaderAnimation();
            
        addChild( p );
            
        p.x = ( stage.stageWidth >> 1 ) - 64;
        p.y = ( stage.stageHeight >> 1 ) - 64;
        }
    }
}



import com.greensock.easing.Cubic;
import com.greensock.TweenNano;
import flash.display.Shape;
    
class PreloaderAnimation extends Shape 
{
    public static var SIZE:Number = 126;
    public static var COLORS:Array = [ 0x04E152, 0xD8C90E, 0xE60000, 0x0A7DDC ];
    public static var DURATION:Number = 0.5;
    public static var DELAY:Number = 0.15;
    public static var RADIUS_RATIO:Number = 1 / 5;
    public static var RADIUS_MIN:Number = 0.6;
    
    public var value:Number = 0;
    
    private var t:Number;
    private var b:Number;
    private var c:Array;
    private var d:Number;
    private var s:Number;
    private var r:Number;
    private var m:Number;
    
    public function PreloaderAnimation() 
    {
        m = RADIUS_MIN;
        t = DURATION;
        d = DELAY;
        c = COLORS.slice();
        s = SIZE;
        r = s * RADIUS_RATIO;
        b = s - r;
        
        tween();
    }
    
    public function dispose():void
    {
        TweenNano.killTweensOf( this );
        graphics.clear();
        if ( parent ) parent.removeChild( this );
    }
    
    private function tween():void
    {
        // Reset tween 
        value = 0;
        
        // Cycle colors 
        c.unshift( c.pop() );
        
        // Tween 
        TweenNano.to( this, t, { 
            
            ease: Cubic.easeInOut,
            value : 1,
            onUpdate: render,
            onComplete: tween,
            delay: d
        });
    }
    
    private function render():void
    {
        graphics.clear();
        
        var x1:Number;
        var y1:Number;
        var x2:Number;
        var y2:Number;
        
        var f:Number = Math.abs( ( value - .5 ) * 2 );  
        
        for ( var i:int = 0; i < 4; i++ ) 
        {
            graphics.beginFill( c[i] );
            
            x1 = i == 0 || i == 3 ? r : b;
            y1 = i > 1 ? b : r;
            x2 = i > 1 ? r : b;
            y2 = x1;
            
            graphics.drawCircle(
                (x2-x1) * value + x1,
                (y2-y1) * value + y1,
                r * m + ( f * (1-m) * r )
            );
            
            graphics.endFill();
        }
    }
    
}