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

Odyssey — 1111

"The thing's hollow—it goes on forever—and—oh my God—it's full of stars!"
package
{
    import flash.display.*;
    import flash.events.Event;
    import flash.filters.DisplacementMapFilter;
    import flash.filters.DisplacementMapFilterMode;
    import flash.geom.*;
    import flash.utils.getTimer;

    // Odyssey — 1111 —————————————————————————————————————————————————————————
    // "The thing's hollow—it goes on forever—and—oh my God—it's full of stars!"
    // —————————————————————————————————————————————————————————— The FlashMafia

    public class Odyssey1111 extends Sprite
    {
        private const NUM_P : int = 2222;
        private const SW : int = 465;
        private const SH : int = 465;
        private const CX : Number = SW >> 1;
        private const CY : Number = SH >> 1;
        /* */
        private var _p : Particle;
        private var _bmd : BitmapData;
        private var _xyFilter : DisplacementMapFilter;
        private var _mapRotBit : Sprite;
        private var _mapRot : Sprite;
        private var _map : BitmapData;
        private var _mtx : Matrix = new Matrix(1, 0, 0, 1, CX, CY);
        private var _dstp : Point = new Point();
        private var _colors : Vector.<uint> = Vector.<uint>([0x808080, 0x552211, 0x992211, 0xAAAAAA, 0xCCCCC0, 0xFFFFF0, 0xFFFFFF, 0xBBBBB8, 0xDDDDD0, 0x708099]);

        public function Odyssey1111()
        {
            stage.stageFocusRect = mouseEnabled = mouseChildren = tabEnabled = tabChildren = false;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.quality = StageQuality.LOW;
            stage.frameRate = 32;
            stage.fullScreenSourceRect = new Rectangle(0, 0, 465, 465);

            /* */

            var bm : Bitmap = new Bitmap(_bmd = new BitmapData(SW, SH, false, 0x000000));
            bm.opaqueBackground = 0x000000;
            addChild(bm);

            _p = new Particle();

            var p : Particle = _p;
            var n : uint = NUM_P;
            while (n-- != 0) {
                p.x = CX;
                p.y = CY;
                p = p.next = new Particle();
            }

            /* create map */

            var cx : int = CX;

            var colors1 : Array = [0xEEEEEE, 0];
            var colors2 : Array = [255, 0];
            var alphas : Array = [1, 1];
            var ratios : Array = [0, 255];

            var mtx1 : Matrix = new Matrix();
            mtx1.createGradientBox(cx * 2, cx * 2);

            var mtx2 : Matrix = new Matrix();
            mtx2.createGradientBox(cx, cx, Math.PI / 2);

            var sh0 : Shape = new Shape();
            sh0.graphics.beginGradientFill(GradientType.LINEAR, colors1, alphas, ratios, mtx1);
            sh0.graphics.drawCircle(cx, cx, cx);
            sh0.graphics.endFill();

            var sh1 : Shape = new Shape();
            sh1.graphics.beginGradientFill(GradientType.LINEAR, colors2, alphas, ratios, mtx2);
            sh1.graphics.drawCircle(cx, cx, cx);
            sh1.graphics.endFill();

            var px : int = SW + 400;
            var py : int = SH + 400;

            var mtx3 : Matrix = new Matrix();
            mtx3.tx = (px - cx * 2) / 2;
            mtx3.ty = (py - cx * 2) / 2;

            _map = new BitmapData(px, py, false, 8355711);
            _map.draw(sh0, mtx3);

            var bmd : BitmapData = new BitmapData(px, py, false, 8355711);
            bmd.draw(sh1, mtx3);

            _map.copyChannel(bmd, bmd.rect, _dstp, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
            _mapRot = new Sprite();
            _mapRotBit = new Sprite();
            _mapRot.addChild(_mapRotBit);

            _xyFilter = new DisplacementMapFilter(_map);

            var bmp : Bitmap = new Bitmap(_map.clone());
            bmp.x = -CX - 200;
            bmp.y = -CY - 200;

            _mapRotBit.addChild(bmp);

            bmd.dispose();

            /* */

            addEventListener(Event.ENTER_FRAME, oef);
        }

        private function oef(e : Event) : void {
            var p : Particle = _p;

            var cnt : uint;
            while (p != null) {
                p.x = p.x + p.vx;
                p.y = p.y + p.vy;

                p.x = (p.x < 0) ? SW : (p.x > SW) ? 0 : p.x;
                p.y = (p.y < 0) ? SH : (p.y > SH) ? 0 : p.y;

                _bmd.setPixel(p.x, p.y, _colors[cnt & 7]);

                ++cnt;

                p = p.next;
            }

            _xyFilter.componentX = BitmapDataChannel.RED;
            _xyFilter.componentY = BitmapDataChannel.BLUE;
            _xyFilter.mode = DisplacementMapFilterMode.IGNORE;
            _xyFilter.mapPoint = _dstp;

            var t : Number = getTimer() / 15000;

            _mapRotBit.rotation = 45 * Math.sin(t * 3);
            _map.draw(_mapRot, _mtx);

            _xyFilter.scaleX = 256 + 128 * Math.sin(t * t);
            _xyFilter.scaleY = 128 + 256 * Math.sin(1 / t);

            _bmd.applyFilter(_bmd, _bmd.rect, _dstp, _xyFilter);
            _bmd.threshold(_bmd, _bmd.rect, _dstp, '<', 4284572001, 4278190080, 16711680, false);
        }
    }
}
internal class Particle
{
    public var next : Particle;
    public var x : Number = 0.0;
    public var y : Number = 0.0;
    public var vx : Number = -1 + 2 * Math.random();
    public var vy : Number = -1.5 + 3 * Math.random();
}