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

Ninja Slash 2+

Simplified, Optimized, Weaponized.
/**
 * Copyright FLASHMAFIA ( http://wonderfl.net/user/FLASHMAFIA )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5YQa
 */

package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.ColorTransform;

    [SWF(width='465', height='465')]
    public class Slaash2 extends Sprite {
        private var bmd : BitmapData;
        private var lux : Lux;
        private var src : Lucioles;
        private var srcBmd : BitmapData;
        private var trailFadeCT : ColorTransform;
        private var fcnt : int;
        private var tx : Number;
        private var ty : Number;

        function Slaash2() {
            stage.stageFocusRect = mouseEnabled = mouseChildren = tabEnabled = tabChildren = false;
            stage.scaleMode = 'noScale';
            stage.align = 'TL';
            stage.quality = 'low';
            stage.frameRate = 64;
            opaqueBackground = 0x0;

            var bm : Bitmap = new Bitmap(bmd = new BitmapData(512, 512, false));
            bm.x = bm.y = (465 - 512) >> 1;
            bm.opaqueBackground = 0x0;
            addChild(bm);

            src = new Lucioles();
            srcBmd = new BitmapData(512, 512);

            lux = new Lux(512, 512);
            trailFadeCT = new ColorTransform(0.985, 0.972, 0.935);

            tx = ty = 0.0;

            addEventListener(Event.ENTER_FRAME, oef);
        }

        private function oef(e : Event) : void {
            fcnt++;

            if (fcnt < 256) {
                if ((fcnt & 15) == 1) {
                    tx = 465 * Math.random();
                    ty = 465 * Math.random();
                }
            } else {
                tx = stage.mouseX;
                ty = stage.mouseY;
            }

            src.update(tx, ty);
            srcBmd.colorTransform(srcBmd.rect, trailFadeCT);
            srcBmd.draw(src, null, null, 'add');

            bmd.lock();
            lux.render(tx, ty, srcBmd, bmd);
            bmd.unlock();
        }
    }
}

import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Shape;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;


internal class Lucioles extends Shape {
    private var blades : Vector.<Blade>;
    private var fcnt : int;

    public function Lucioles() {
        blades = new Vector.<Blade>(3, true);

        var i : uint = blades.length;
        while (i-- != 0) blades[i] = new Blade();
    }

    public function update(tx : Number, ty : Number) : void {
        fcnt++;

        var rot : Number = ((fcnt & 63) / 64) * 6.283185307179586;
        var ang : Number = rot + 16 + 8 * Math.sin(rot);

        graphics.clear();
        graphics.lineStyle(8, 0x888482, 1.0, false, 'none', 'none');

        for each (var blade : Blade in blades) {
            var inertiaX : Number = (blade.px0 - blade.px1) + blade.px0;
            var inertiaY : Number = (blade.py0 - blade.py1) + blade.py0;

            ang += 2.0;

            inertiaX = inertiaX * 0.92 + (tx + 16 * Math.cos(ang)) * 0.08;
            inertiaY = inertiaY * 0.92 + (ty + 16 * Math.sin(ang)) * 0.08;

            blade.px1 = blade.px0;
            blade.py1 = blade.py0;
            blade.px0 = inertiaX;
            blade.py0 = inertiaY;

            graphics.moveTo(blade.px0, blade.py0);
            graphics.lineTo(blade.px1, blade.py1);
        }
    }
}

internal class Blade {
    public var px0 : Number = 0.0;
    public var py0 : Number = 0.0;
    public var px1 : Number = 0.0;
    public var py1 : Number = 0.0;

    function Blade() {
    }
}

internal class Lux {
    private var ofscr : BitmapData;
    private var ct : ColorTransform;
    private var mtx : Matrix;
    private var dstp : Point;
    private var rect : Rectangle;

    public function Lux(width : int, height : int) {
        ofscr = new BitmapData(width, height);
        rect = ofscr.rect;

        ct = new ColorTransform(0.04, 0.1, 0.64);
        mtx = new Matrix();
        dstp = new Point();
    }

    public function render(tx : Number, ty : Number, input : BitmapData, output : BitmapData) : void {
        output.copyPixels(input, rect, dstp);
        output.colorTransform(rect, ct);

        mtx.identity();
        mtx.translate(-tx, -ty);
        mtx.scale(1.0015, 1.0015);
        mtx.translate(tx, ty);

        var pass : uint = 8;
        while (pass-- != 0) {
            ofscr.copyPixels(output, rect, dstp);
            output.draw(ofscr, mtx, null, BlendMode.ADD, null, true);
            mtx.concat(mtx);
        }
    }
}