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

STELLA

/**
 * Copyright spanvega ( http://wonderfl.net/user/spanvega )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xHXa
 */

package
{
    import flash.geom.*;
    import flash.events.*;
    import flash.display.*;
    import flash.filters.*;

    import com.bit101.components.*;

    /**  @author SPANVEGA // CHRISTIAN  **/

    [ SWF (width = '465', height = '465', backgroundColor = '0x000000', frameRate = '50')]

    public class STELLA extends Sprite
    {
        private var tran : ColorTransform = new ColorTransform (1, 1, 1, 0.95);

        private var blur : BlurFilter = new BlurFilter (2.5, 2.5, 1);

        private var seed : int = Math.random () * uint.MAX_VALUE; 

        private var p_vec : Vector.<PARTICLE> = new <PARTICLE>[];
        private var m_vec : Vector.<Matrix> = new <Matrix>[];
        private var blend : Vector.<String> = new <String>[];

        private var o : Array = [new Point (), new Point ()];

        private var size : int = 465, half : int = size >> 1;

        private var rect : Rectangle = new Rectangle (0, 0, size, size);

        private var emission : Boolean = true;
        private var quantity : Number = 75;
        private var velocity : Number = 5;
        private var speed : Number = 1.5;

        private var limit : int = 10000;

        private var image : BitmapData;
        private var pixel : BitmapData;
        private var model : BitmapData;

        private var q : ProgressBar;

        private var rad : Number;
        private var num : Number;

        private var m : Matrix, s : String;
        private var p : PARTICLE;

        private var r : Number, g : Number;
        private var b : Number, c : uint;

        private var i : int;


        public function STELLA ()
        {
            stage ? init () : addEventListener (Event.ADDED_TO_STAGE, init);
        }

        private function init () : void
        {
            if (hasEventListener (Event.ADDED_TO_STAGE))
            {removeEventListener (Event.ADDED_TO_STAGE, init);}

            stage.scaleMode = 'noScale';

            m_vec.push
            (
                new Matrix ( 1, 1,-1, 1, half,-half),
                new Matrix (-1,-1,-1, 1, half * 3, half),
                new Matrix (-1,-1, 1,-1, half, half * 3),
                new Matrix ( 1, 1, 1,-1,-half, half)
            );

            blend.push
            (
                BlendMode.INVERT,   BlendMode.HARDLIGHT,
                BlendMode.MULTIPLY, BlendMode.MULTIPLY
            );

            //

            model = new BitmapData (half, half, false, 0);

            image = new BitmapData (size, size, true, 0);

            pixel = image.clone ();

            //

            addChild (new Bitmap (image));

            addChild (new Bitmap (pixel));

            gui ();

            //

            frame (); stage.addEventListener (Event.ENTER_FRAME, frame);
        }

        private function frame (e : Event = null) : void
        {
            o[1].x =- (o[0].x += speed);
            o[1].y =- (o[0].y -= speed);

            // --o CANVAS

            model.perlinNoise (233, 233, 2, seed, true, false, 7, false, o);

            for each (s in blend) model.draw (model, null, null, s);

            for each (m in m_vec) image.draw (model, m);

            // --o PIXELS

            pixel.lock ();

            pixel.colorTransform (rect, tran);
            pixel.applyFilter (pixel, rect, rect.topLeft, blur);

            for each (p in p_vec)
            {
                c = image.getPixel (p.x, p.y);

                r = (c <<  8 >>> 24) / 0x80;
                g = (c << 16 >>> 24) / 0x80;
                b = (c << 24 >>> 24) / 0x40;

                p.x += p.vx * (r - b);
                p.y += p.vy * (g - b);

                pixel.setPixel32 (p.x, p.y, p.c);

                if (p.y < 0 || p.y > size || p.x < 0 || p.x > size)
                {
                    p_vec.splice (p_vec.indexOf (p), 1); p = null;
                }
            }

            //

            num = (emission ? (p_vec.length < limit ? quantity % (limit - p_vec.length) : 0) : 0);

            for (i = 0; i < num; i++)
            {
                p = new PARTICLE ();

                p.c  = 0xFFFFFFFF;
                p.x  = half;
                p.y  = half;

                rad = (Math.random () * 360) * (3.1415926535 / 180);

                p.vx = Math.cos (rad) * velocity;
                p.vy = Math.sin (rad) * velocity;

                p_vec.push (p);
            }

            pixel.unlock ();

            q.value = p_vec.length / limit;
        }

        private function gui () : void
        {
            with (Style) { BACKGROUND = LABEL_TEXT = DROPSHADOW = 0xFFFFFF; BUTTON_FACE = PROGRESS_BAR = 0x000000; }

            with (addChild (new Sprite ()))
            { graphics.beginFill (0x000000, 0.5); graphics.drawRect (0, 440, 465, 25); }

            var w : HUISlider = new HUISlider (this, 10, 443, 'VELOCITY', function () : void { velocity = w.value; });
            with (w) { setSliderParams (1, 10, velocity); width = 160; labelPrecision = 2; tick = 0.01; draw (); }

            var s : HUISlider = new HUISlider (this, 170, 443, 'SPEED', function () : void { speed = s.value; });
            with (s) { setSliderParams (-2.5, 2.5, speed); width = 160; labelPrecision = 2; draw (); }

            var c : CheckBox = new CheckBox (this, 333, 447, '', function () : void { emission = c.selected; });
            c.selected = emission;

            q = new ProgressBar (this, 353, 447);
            with (q) { height = 10; draw (); }
        }
    }
}

//

internal class PARTICLE
{
    public var c : uint;
    public var x : Number, vx : Number;
    public var y : Number, vy : Number;
}