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

PerlinWaves

@author: BigRobot
@date  : 13 jan 2009
//@author: BigRobot
//@date  : 13 jan 2009

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.filters.GlowFilter;
    
    [SWF(backgroundColor="0x00")]
    public class Waves extends Sprite
    {

        private var __bmd  :BitmapData;
        private var __val  :Number = 0;
        private var __angle:Number = 0;
        private var __color:Number = 0;
        public function Waves() {
            this.filters = [ new GlowFilter( 0x00ffff, 1, 3, 3 ) ]
            build();
        }

        private function build():void {
            __bmd = new BitmapData( 50, 50, true, 0 ); 
           this.addEventListener( Event.ENTER_FRAME, doMagic );
        }
        
        private function doMagic( evt:Event ):void {
            drawBMD();
            drawLines();
        }

       
        private function drawBMD():void {
           __bmd.perlinNoise(__bmd.width / 3,__bmd.height / 3,3,6456,true,true,2|1,false,[new Point(__val +=1,0),
            new Point(__val/10,0),new Point(0,0)]);
        }

        private function drawLines():void {
            __angle = (Math.PI / 180);
	    __color = __bmd.getPixel( Math.cos( __angle ) * __bmd.width, Math.sin( __angle ) * __bmd.height  );
	    this.graphics.clear();
	    for (var h:int = 0; h < __bmd.height ; h++) {
	        var thickness:Number  = __bmd.getPixel( 0, h ) / 100000;
	        this.graphics.lineStyle( thickness / 35, __color, .05);
	        for (var w:int = 0; w < __bmd.width; w++) {
	            var __value:Number = __bmd.getPixel( w, h ) / 100000;
	             this.graphics.lineTo( w * 11, __value * 2  );
		}
		this.graphics.moveTo( -20,  h );
	    }
        }
    }

}