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

Perlin Noise

package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    import frocessing.math.PerlinNoise;

    public class Perlin extends Sprite {
        private var perlin:PerlinNoise = new PerlinNoise();
        private var noiseScale:Number = 0.02;
        private var n:Number = 0.0;
        private var d:Number = 0.4;
        private var a:Array = [];

        public function Perlin() {
            for (var j:int = 0; j < 4; ++j) {
                var s:Shape = new Shape();
                s.alpha = 0.1;
                a[j] = s;
                addChild(s);
            }
            addEventListener(Event.ENTER_FRAME, enterFrame);
        }

        private function enterFrame(e:Event):void {
            n += d;
            for (var j:int = 0; j < 4; ++j) {
                var y:int = j * 10;
                var s:Shape = a[j];
                s.graphics.clear();
                s.graphics.beginFill(0x0000FF);
                s.graphics.moveTo(0, 465);
                for (var x:int = 0; x < 233; x++) {
                    var noiseVal:Number = perlin.noise((n+x)*noiseScale, (-n+y)*noiseScale, y*noiseScale);
                    s.graphics.lineTo(x*2, 200+noiseVal*100);
                }
                s.graphics.lineTo(465, 465);
                s.graphics.endFill();
            }
        }
    }
}