forked from: Chapter 36 Example 16

by bambula.filip1 forked from Chapter 36 Example 16 (diff: 4)
♥0 | Line 28 | Modified 2015-09-02 22:32:09 | MIT License
play

ActionScript3 source code

/**
 * Copyright bambula.filip1 ( http://wonderfl.net/user/bambula.filip1 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/urrH
 */

// forked from actionscriptbible's Chapter 36 Example 16
package {
  import flash.display.*;
  import flash.events.Event;
  import flash.events.KeyboardEvent;
  import flash.events.TimerEvent;
  [SWF(frameRate="2")]
  public class ch36ex16 extends Sprite {
    protected var bmp:BitmapData;
    protected var stitch:Boolean = true;
    public function ch36ex16() {
      bmp = new BitmapData(200, 200);
      var shape:Shape = new Shape();
      shape.graphics.lineStyle(0, 0, 0);
      shape.graphics.beginBitmapFill(bmp);
      shape.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
      shape.graphics.endFill();
      addChild(shape);

      stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
      addEventListener(Event.ENTER_FRAME, onEnterFrame);100
    }
    protected function onKeyDown(event:KeyboardEvent):void {
      stitch = !stitch;
    }
    private function onEnterFrame(event:Event):void {
      bmp.perlinNoise(100, 100, 2, Math.random()*100000000000000, stitch, true, 1, true);
    }
  }
}