The following code makes a BitmapData object with Perlin noise, and then uses that object as a bitmap fill. Because the stitch parameter is false, the edges are visible as it tiles.
package {
import flash.display.BitmapData;
import flash.display.Shape;
import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Main extends Sprite {
private var _bitmapData:BitmapData = new BitmapData(200, 200);
public function Main() {
var shape:Shape = new Shape();
shape.graphics.lineStyle(0, 0, 0);
shape.graphics.beginBitmapFill(_bitmapData);
shape.graphics.drawRect(0, 0, 600, 400);
shape.graphics.endFill();
addChild(shape);
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
}
private function timerHandler(event:TimerEvent):void {
_bitmapData.perlinNoise(100, 100, 1, Math.random() * 100000, false, false);
}
}
}
Related examples in the same category