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

BetweenAS3だけで花火っぽいの

Get Adobe Flash player
by uwi 11 Jan 2010
/**
 * Copyright uwi ( http://wonderfl.net/user/uwi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lHqE
 */

package {
    import flash.display.*;
    import flash.filters.*;
    import flash.geom.*;
    import org.libspark.betweenas3.*;
    import org.libspark.betweenas3.tweens.*;
    import org.libspark.betweenas3.core.easing.*;
    public class Test extends Sprite {
        public function Test() {
            Wonderfl.capture_delay(10);
            var bmd : BitmapData = new BitmapData(465, 465, false, 0x000000);
            addChild(new Bitmap(bmd));
            
            var r : Function = Math.random;
            var ct : ColorTransform = new ColorTransform(0.97, 0.97, 0.97);
            var bf : BlurFilter = new BlurFilter(6, 6);
            var f : Function;
            
            var rep : ITween = BetweenAS3.repeat(
                BetweenAS3.delay(
                    BetweenAS3.func(f = function(x : Number = 0, y : Number = 0, sz : Number = 7) : void {
                        if(x == 0)x = r() * 465;
                        var ph : IObjectTween, pr : ITween;
                        pr = BetweenAS3.parallel(
                            ph = BetweenAS3.physical({}, {y : 465}, {y : y},
                                new PhysicalAccelerate(-Math.random() * 100, 100, 1)
                                ),
                            BetweenAS3.tween(ph.target, 
                                {x : x + r() * 300 - 150, r : r() * 0xff, g : r() * 0xff, b : r() * 0xff}, 
                                {x : x, r : r() * 0xff, g : r() * 0xff, b : r() * 0xff}, 
                                ph.duration)
                        );
                        pr.play();
                        pr.onUpdate = function() : void {
                            var o : * = ph.target;
                            bmd.fillRect(new Rectangle(o.x - sz, o.y - sz, sz * 2, sz * 2), o.r << 16 | o.g << 8 | o.b);
                            if(sz > 1 && o.y > 50 && r() < 0.02){
                                BetweenAS3.func(f, [o.x, o.y, sz - 1]).play();
                                BetweenAS3.func(f, [o.x, o.y, sz - 1]).play();
                                BetweenAS3.func(f, [o.x, o.y, sz - 1]).play();
                                pr.stop();
                            }
                        };
                    }),
                    0, 0.2),
                999999
            );
            rep.play();
            rep.onUpdate = function() : void {
                bmd.lock();
                bmd.colorTransform(bmd.rect, ct);
                bmd.applyFilter(bmd, bmd.rect, new Point(), bf);
                bmd.unlock();
            };
        }
    }
}