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

The Ring

// forked from yasnis's forked from: Rainbow Ring
// forked from yasnis's Rainbow Ring
package {
    import flash.display.*;
    import flash.events.Event;
    import flash.filters.*;
    import flash.geom.*;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            initialize();
        var c:Shape;
        var p:Object;
            var l:int = 6;
        for (var i:int = 0; i < l; i++) {
            c = createCircle(40+ 30 * Math.random());
            p = new Object();
            p.r = 10 + 15* Math.random();
            p.theta = Math.random() * PI * 2;
            p.vtheta = .1*(Math.random()*2-1);
            balllist[i] = c;
            poslist[i] = p;
                c.filters = [blur];
            metaball.addChild(c);
        }
        addEventListener(Event.ENTER_FRAME, update);
        addEventListener(Event.ENTER_FRAME, updateShape);
        addEventListener(Event.ENTER_FRAME, updateFilter);
        }
        private function initialize():void {
            stage.quality = StageQuality.MEDIUM;
            stage.frameRate = 60;
            center.x = stage.stageWidth/4>>0;
            center.y = stage.stageHeight/4>>0;
            var s:Shape = new Shape();
            var g:Graphics = s.graphics;
            g.beginFill(0x000000);
            g.drawRect(0,0,100,100);
            s.width = stage.stageWidth;
            s.height = stage.stageHeight;
            addChildAt(s,0);
        holder = new Sprite();
            metaball = new Sprite();
            blur = new BlurFilter(26, 26, 3);
        glow_in = new GlowFilter(0xffffff,.8,28,28,2,2,true);
        glow_out = new GlowFilter(0,.8,16,16,2.5,2,false);
            bmpd = new BitmapData(stage.stageWidth/2,stage.stageHeight/2,true,0xff000000);
            bmp = new Bitmap(bmpd);
            holder.addChild(bmp);
            main_bmpd = new BitmapData(stage.stageWidth/2,stage.stageHeight/2,true,0xff000000); 
            main = new Bitmap(main_bmpd);
            main.blendMode = BlendMode.ADD;
            main.x=main.width/2;
            main.y=main.height/2;
            addChild(main);
        }    
    private function updateShape(e:Event):void {
            bmpd.fillRect(bmpd.rect,0x00000000);
            bmpd.draw(metaball);
            bmpd.threshold(bmpd,bmpd.rect,new Point(0, 0),">",0x30000000,0xff000000);
        }
    private function updateFilter(e:Event):void {
            if(++color_count% interval==0){
                huemarker += Math.random()*180;
                interval = Math.random()*10+10;
                color_count= 0;
            }
            hue += (huemarker-hue)*0.1;
            glow_out.color=glow_in.color=getRGB(hue,saturation,blightness);
            bmp.filters=[glow_in,glow_out];
        }
    private function update(e:Event):void {
            if (++bmp_count%5==0) {
                bmp_count=0;
                duplicateImage();
            }
        var c:Shape;
        var p:Object;
            var l:int = balllist.length;
        for (var i:int = 0; i < l; i++) {
                c = balllist[i];
                p = poslist[i];
                p.theta+=p.vtheta;
                c.x = p.r*Math.cos(p.theta)+center.x;
                c.y = p.r*Math.sin(p.theta)+center.y;
        }
            main_bmpd.fillRect(main_bmpd.rect,0x000000);
            main_bmpd.draw(holder);
    }
        public function createCircle(r:Number):Shape{
            var s:Shape = new Shape();
        var g:Graphics = s.graphics;
        g.beginFill(0xffffff);
        g.drawCircle(0, 0, r);
        return s;
        }

        public function duplicateImage():void {
            var bd:BitmapData = new BitmapData(stage.stageWidth/2,stage.stageHeight/2,true,0xff000000);
            bd.copyPixels(main_bmpd,main_bmpd.rect,new Point());
            var b:Bitmap = new Bitmap(bd);
            b.blendMode = BlendMode.ADD;
            b.alpha = .5;
            b.x=main.width/2;
            b.y=main.height/2;
            addChildAt(b,1);
            b.addEventListener(Event.ENTER_FRAME, fadeImage);
        }
    private function fadeImage(e:Event):void {
            var b:Bitmap = e.target as Bitmap;
            b.alpha-=.005;
            if(b.alpha<0){
                b.removeEventListener(Event.ENTER_FRAME, fadeImage);
                b.bitmapData.dispose();
                removeChild(b);
            }
        }
    public const RGB_MAX:int = 255; public const H_MAX:int = 360; public const SB_MAX:int = 100;
    public function getRGB(h:Number = 0, s:Number = 100 , b:Number=100):uint {
        h = h % H_MAX >> 0;
        s = Math.max(0, Math.min(s , SB_MAX));
        b = Math.max(0, Math.min(b , SB_MAX));
        var red:Number,green:Number,blue:Number;
        if (s == 0){
            red = green = blue = b*RGB_MAX/SB_MAX;
        }else{
            var hi:Number = Math.floor(h / (H_MAX / 6)) % 6;
            var f:Number = h / (H_MAX / 6) - hi;
            var p:Number = b / SB_MAX * ( 1 - s / SB_MAX );
        var q:Number = b / SB_MAX * ( 1 - s / SB_MAX  * f);
        var t:Number = b / SB_MAX * ( 1 - s / SB_MAX  * ( 1 - f));
        switch (hi) { 
                case 0 : red = b / SB_MAX; green = t; blue = p; break; 
            case 1 : red = q; green = b / SB_MAX; blue = p; break;
            case 2 : red = p; green = b / SB_MAX; blue = t; break; 
            case 3 : red = p; green = q; blue = b / SB_MAX; break; 
            case 4 : red = t; green = p; blue = b / SB_MAX; break; 
            case 5 : red = b / SB_MAX; green = p; blue = q; break; 
        }
                red     =  Math.round(red * RGB_MAX);
                green   =  Math.round(green * RGB_MAX);
                blue    =  Math.round(blue * RGB_MAX);
        }
        return red << 16 | green << 8 | blue;
    }
    private const PI:Number = Math.PI;
        private var main_bmpd:BitmapData;
        private var main:Bitmap;
        private var holder:Sprite;
        private var metaball:Sprite;
        private var balllist:Array = [];
        private var poslist:Array = [];
    private var center:Object = {};
        private var glow:GlowFilter;
        private var glow_in:GlowFilter;
        private var glow_out:GlowFilter;
        private var blur:BlurFilter;
        private var huemarker:Number = Math.random()*360;
        private var hue:Number = Math.random()*360;
        private var saturation:Number = 0;
        private var blightness:Number = 60;
        private var bmpd:BitmapData;
        private var bmp:Bitmap;
        private var bmp_count:int = 0;
        private var color_count:int = 0;
        private var interval:int = Math.random()*30+30;
    private const cmf:ColorMatrixFilter = new ColorMatrixFilter([  
        1, 0, 0, 0, 0,
        0, 1, 0, 0, 0,
        0, 0, 1, 0, 0,
        0, 0, 0, 1, 0
        ]);
    }
}