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

Interactive Perlin Noise

Move the mouse around to change the octaves and random seed in the Perlin noise.  It moves based on where the mouse is as well.
Get Adobe Flash player
by tronster 11 Nov 2010
/**
 * Copyright tronster ( http://wonderfl.net/user/tronster )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/txG1
 */

package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;

    /**
     * Move the mouse to change the Perlin Noise
     * @author Tronster, http://tronster.com
     */
    public class FlashTest extends Sprite {
        private var bitmap:Bitmap;
        private var offsets:Array;  
      
      
        public function FlashTest() {
            bitmap = new Bitmap( new BitmapData( stage.stageWidth, stage.stageHeight ) );
            addChild( bitmap );
            
            offsets = [];
            for (var i:int = 0; i < 8; i++ )
                offsets[i] = new Point(0,0);
            addEventListener( Event.ENTER_FRAME, onFrame );            
        }
        
        public function onFrame( e:Event ) :void {
            var octives :int = 1 + ( ( stage.mouseY / stage.stageHeight ) * 8 );
            var seed    :int = stage.mouseX;
            
            for (var i:int = 0; i < offsets.length; i++ ) {
                offsets[i].x += ((stage.mouseX < (stage.stageWidth * 0.5)) ? -1 : 1) * (i%2 ? 1 : -1);
                offsets[i].y += ((stage.mouseY < (stage.stageHeight * 0.5)) ? -1 : 1) * (i%2 ? 1 : -1);         
            }
            bitmap.bitmapData.perlinNoise(
                stage.stageWidth, stage.stageHeight,
                octives, seed, false, false, 7, false, offsets);
        }

    }
}