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

Vortex

Jason Smith 2010
Get Adobe Flash player
by Venom 28 Jul 2010
/**
 * Copyright Venom ( http://wonderfl.net/user/Venom )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3ClZ
 */

/**
 * Jason Smith 2010
 */
package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.filters.BlurFilter;
    import flash.events.Event;
    
    [SWF(frameRate=31)]
    final public class Vortex extends Sprite {
        private const CENTRE:Number = 232.5;
        
        private var radius:Number = 0;
        
        private var blur:BlurFilter = new BlurFilter(4,1,2);
        private var blur2:BlurFilter = new BlurFilter(2,4,2);
        private var blur3:BlurFilter = new BlurFilter(5,5,2);

        private var bmd:BitmapData;
        private var bmd2:BitmapData;
        private var bmd3:BitmapData;
        
        private var canvas:Bitmap;
        private var canvas2:Bitmap;
        private var canvas3:Bitmap;

        public function Vortex() {
            init();  
        }
        
        private function init():void {
            bmd = new BitmapData(stage.stageWidth,stage.stageHeight,false,0x000000);
            canvas = new Bitmap(bmd);
            addChild(canvas);
            
            bmd2 = new BitmapData(stage.stageWidth,stage.stageHeight,false,0x000000);
            canvas2 = new Bitmap(bmd2);
            addChild(canvas2);
            canvas2.blendMode = BlendMode.ADD;
            
            bmd3 = new BitmapData(stage.stageWidth,stage.stageHeight,false,0x000000);
            canvas3 = new Bitmap(bmd3);
            addChild(canvas3);
            canvas3.blendMode = BlendMode.ADD;
            
            addEventListener("enterFrame",loop,false,0,true);
        }
        
        private var ri:Number = 0.1;
        private var oi:Number = 0.1;
        private var omega:Number = 0;
        private function loop(evt:Event):void {
            for (var i:uint = 0; i<10000; i++) {
                var x:Number = CENTRE + Math.sin(Math.tan(omega))*radius;
                var y:Number = CENTRE + Math.cos(omega)*radius;
                var x2:Number = CENTRE + Math.sin(omega)*radius;
                var y2:Number = CENTRE + Math.cos(Math.tan(omega))*radius;
                
                bmd.setPixel(x,y,Math.random()*0xFFAA);
                bmd2.setPixel(x2,y2,Math.random()*0xFFAA);
                bmd3.setPixel(x2,y,0xFFFFFF);
                omega+=oi;
                radius+=ri;
            }
            radius = omega = 0; // reset
            ri+=0.00001;
            oi+=0.000001;  // increase rate of accumulating radius and angle per cycle
            bmd.applyFilter(bmd,bmd.rect,new Point(),blur);
            bmd2.applyFilter(bmd2,bmd2.rect,new Point(),blur2);
            bmd3.applyFilter(bmd3,bmd3.rect,new Point(),blur3);
        }
    }
}