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

forked from: Saqoosha challenge for amateurs

Get Adobe Flash player
by awef 21 Sep 2009
/**
 * Copyright awef ( http://wonderfl.net/user/awef )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wVst
 */

// forked from checkmate's Saqoosha challenge for amateurs
package
{
    import flash.display.Sprite;
    
    [SWF(width=465, height=465, backgroundColor=0xeeeeec, frameRate=30)]
    public class main extends Sprite
    {
        public function main()
        {
            for (var i:int = 0; i < 300; i++)
                addChild(new bubble());
        }
    }
}

class bubble extends flash.display.Sprite
{
    import flash.filters.BlurFilter;
    import gs.TweenMax;
    import gs.easing.*;
    
    public var grad:Gradation = new Gradation(0xff0000, 0xff4400, 0xffbb00, 0xbbbb00, 0x00bb00, 0x0000ff);
    public var r:int = Math.random() * 10 + 10;
    
    function bubble()
    {
        var delay:Number = Math.random() * 4;
        x = 465 / 2;
        y = 465 + r;
        alpha = 0.4;
        filters = [new BlurFilter()];
        TweenMax.to(this, 4, { delay : delay, loop : 0, y : 100, ease : Back.easeOut, onUpdate : function():void {
            graphics.clear();
            graphics.beginFill(grad.getColor(y / 465));
            graphics.drawCircle(0, 0 , r);
            graphics.endFill();
        }} );
        TweenMax.to(this, 4, { delay : delay, loop : 0, x : Math.random() * 465, ease : Linear.easeNone } );
        TweenMax.to(this, 4, { delay : delay, loop : 0, alpha : 0, ease : Cubic.easeIn } );
    }
}


/* 以下、お題のクラス */
/* importだけ中に引っ込ませてる */

class Gradation {
import frocessing.color.ColorLerp;

import org.libspark.betweenas3.core.easing.IEasing;
import org.libspark.betweenas3.easing.Linear;
    
    private var _colors:Array;
    private var _easing:IEasing;
    
    public function Gradation(...args) {
        _colors = args.concat();
        _easing = Linear.linear;
    }
    
    public function setEasing(easing:IEasing):void {
        _easing = easing;
    }
    
    public function getColor(position:Number):uint {
        position = (position < 0 ? 0 : position > 1 ? 1 : position) * (_colors.length - 1);
        var idx:int = position;
        var alpha:Number = _easing.calculate(position - idx, 0, 1, 1);
        if (alpha == 0) {
            return _colors[idx];
        } else {
            return ColorLerp.lerp(_colors[idx], _colors[idx + 1], alpha);
        }
    }
}