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

PIPELINE

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

// forked from codeonwort's transition 3D rotatable
// forked from codeonwort's transition 3D
// forked from codeonwort's forked from: transition
// forked from Nyarineko's transition

package
{
    /*
    *    RESET BY CLIC
    *     -------------
    *    SUBJECT TO A LAST MODIFICATION
    */

    import flash.geom.Point;
    import flash.geom.Vector3D;
    import flash.geom.Rectangle;
    import flash.geom.ColorTransform;

    import flash.display.Shape;
    import flash.display.Sprite;    
    import flash.display.Bitmap;
    import flash.display.Graphics;
    import flash.display.BitmapData;

    import flash.events.Event;
    import flash.events.MouseEvent;

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

    public class PIPELINE extends Sprite
    {
        private var ct : ColorTransform = new ColorTransform (1, 1, 1, 0.15);
        private var vp : Vector.<Particle> = new Vector.<Particle>();
        private var track : Vector.<Vector3D>;

        private const M_WIDTH:Number = 465;
        private const M_HEIGH:Number = 465;
        private const OX:Number = 465 / 2;
        private const OY:Number = 465 / 2;
        private var divider : uint = 35;
        private const V:Number = 2;
        private var zRate : Number;
        private var max:uint = 3;
        private var ran : Number;

        private var shape : Shape = new Shape ();
        private var g : Graphics = shape.graphics;
        private var canvas:BitmapData;
        private var p : Particle;


        public function PIPELINE ()
        {
            Wonderfl.disable_capture ();

            stage.scaleMode = 'noScale';

            graphics.beginFill(0);
            graphics.drawRect (0, 0, M_WIDTH, M_HEIGH);
            graphics.endFill();

            //

            canvas = new BitmapData(M_WIDTH, M_HEIGH, false, 0);
            addChild (new Bitmap (canvas));

            Particle.originX = OX;
            Particle.originY = OY;

            init ();

            stage.addEventListener (MouseEvent.CLICK,  init);
            stage.addEventListener (Event.ENTER_FRAME, update);
        }

        private function init (e : MouseEvent = null) : void
        {
            vp.length = 0;
            //
            for (var i : uint = 0; i < max; i++)
            {
                p = new Particle ();
                p.phi = 360 * i / max;
                p.theta = Math.random() * 180;
                p.phiVel = 1;
                p.radius = 1;
                p.thetaVel = 0;
                //
                vp.push (p);
            }
        }

        private function update (e : Event):void
        {
            Particle.theta0 += (mouseX - OX) / divider;
            Particle.phi0   -= (mouseY - OY) / divider;

            //

            g.clear();
            canvas.lock();

            for each (var p : Particle in vp)
            {
                ran = Math.random();

                if(ran < 0.1){
                    p.phiVel = p.thetaVel = 0;
                    p.radVel = V;
                }else if(ran < 0.2){
                    p.phiVel = -V;
                    p.radVel = p.thetaVel = 0;
                }else if(ran < 0.3){
                    p.phiVel = V;
                    p.radVel = p.thetaVel = 0;
                }else if(ran < 0.4){
                    p.thetaVel = V;
                    p.phiVel = p.radVel = 0;
                }else if(ran < 0.5){
                    p.thetaVel = -V;
                    p.phiVel = p.radVel = 0;
                }else if (ran < 0.504) {
                    var newP:Particle = new Particle ();
                    newP.phi = p.phi;
                    newP.theta = p.theta;
                    newP.radius = p.radius;
                    //
                    vp.push (newP);
                    if(p.phiVel == 0){
                        newP.phiVel = 0;
                        newP.radVel = 1;
                    }else{
                        newP.phiVel = Math.random() < 0.5 ? -1 : 1;
                        newP.radVel = 0;
                    }
                }
                p.radius += p.radVel;
                p.phi    += p.phiVel;
                p.theta  += p.thetaVel;

                p.saveCurrentCoord();
                //
                track = p.getTrack();

                g.moveTo(track[0].x, track[0].y);

                for each (var v : Vector3D in track)
                {
                    zRate = (v.z + p.radius) / (p.radius + p.radius);
                    g.lineStyle
                    (
                        1, 0x009999 << (zRate * 25), 1, false, 'normal', 'none'
                    );
                    g.lineTo (v.x, v.y);
                }
            }

            canvas.colorTransform (canvas.rect, ct);
            canvas.draw(shape, null, null, 'add');
            canvas.unlock();
        }
    } 
}

import flash.geom.Vector3D;

internal class Particle
{
    public static var originX:Number;
    public static var originY:Number;
    private static var t0:Number = 0; // theta0
    private static var p0:Number = 0; // phi0

    private static const K:Number = Math.PI / 180;
    private static const Kinv:Number = 180 / Math.PI;

    private var _theta:Number = 0;
    private var _phi:Number = 0;
    public var radius:Number = 0;
    public var thetaVel:Number = 0;
    public var phiVel:Number = 0;
    public var radVel:Number = 0;

    public var track:Vector.<Vector3D> = new Vector.<Vector3D>();

    public function saveCurrentCoord() : void
    {
        track.push
        (
            new Vector3D (radius, _phi, _theta)
        );
    }

    public function getTrack () : Vector.<Vector3D>
    {
        var t : Vector.<Vector3D> = new Vector.<Vector3D>();

        for each (var v : Vector3D in track)
        {
            t.push
            (
                new Vector3D
                (
                    originX + v.x * Math.cos(v.y + p0) * Math.cos(v.z + t0),
                    originY + v.x * Math.sin(v.y + p0),
                    v.x * Math.cos(v.y + p0) * Math.sin(v.z + t0)
                )
            );
        }
        return t;
    }

    public function get phi():Number { return _phi * Kinv }
    public function set phi(v:Number):void { _phi = v * K }
    
    public function get theta():Number { return _theta * Kinv }
    public function set theta(v:Number):void { _theta = v * K }
    
    public static function get theta0():Number { return t0 * Kinv }
    public static function set theta0(v:Number):void { t0 = v * K }
    public static function get phi0():Number { return p0 * Kinv }
    public static function set phi0(v:Number):void { p0 = v * K }
}