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

forked from: Perlin Noise

Get Adobe Flash player
by kojiOGATA 24 Feb 2010
// forked from flashrod's Perlin Noise
package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    import frocessing.math.PerlinNoise;

    import flash.text.TextField;
    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 = [];
        private var tf:TextField;

        public function Perlin() {
        		tf = new TextField();
        		tf.width = 465;
        		tf.text = "default";
        		addChild(tf);
            for (var j:int = 0; j < 1; ++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 < 1; ++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 <= 75; x++) {
                    var noiseVal:Number = perlin.noise((n+x)*noiseScale, (-n+y)*noiseScale, y*noiseScale);
                    tf.text = String(noiseVal);
                    s.graphics.lineTo(x*6.2, 200+noiseVal*30);
                }
                s.graphics.lineTo(465, 465);
                s.graphics.endFill();
            }
        }
    }
}