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

Bitmapdata.perlinNoise

コマンドのループby俺俺コマンド perlinNoise版
// forked from nium's forked from: forked from: forked from: Bitmapdata.noise
// forked from northprint's forked from: forked from: Bitmapdata.noise
// forked from northprint's forked from: Bitmapdata.noise
// forked from northprint's Bitmapdata.noise
//コマンドのループby俺俺コマンド perlinNoise版
// write as3 code here..
package {
	import flash.display.*;
	import flash.events.*;
	import jp.progression.commands.*;
	import jp.progression.events.*;
	import flash.geom.Point;

	public class NoiseTest extends MovieClip {
		
		private var _bitmapdata:BitmapData;
		private var _bitmap:Bitmap;
		
		private var _loop:LoopCommand;
		
		private var _noiseMode:int = 0;

		private var _offset:Array = [new Point(0,0),new Point(0,0)];		
		public function NoiseTest() {
			_bitmapdata = new BitmapData( stage.stageWidth, stage.stageHeight, true );
			_bitmap = new Bitmap( _bitmapdata );
			addChild( _bitmap );
			
			addEventListener( Event.ENTER_FRAME, _enterFrame );
			
			_loop = new LoopCommand(
				new SerialList( null,
					new Wait( 3000 ),
					function():void { _noiseMode = ++_noiseMode % 3; }
				),
				function():Boolean { return false; }
			);
			
			_loop.execute();
		}
		
		private function _enterFrame( e:Event ):void {
			_offset[0].x += 2;
			_offset[1].y += 2;
			switch ( _noiseMode ) {
				case 0	: { _bitmapdata.perlinNoise(50, 50, 2, 1, false, true, 4 | 2 | 1, false, _offset);break;}
				case 1	: { _bitmapdata.perlinNoise(50, 100, 2, 1, false, true, 1 | 2 | 2, false, _offset);break;}
				case 2	: { _bitmapdata.perlinNoise(100, 50, 2, 1, false, true, 4 | 1 | 4, false, _offset);break;}
			}
		}
	}
}

import jp.progression.commands.*;  
import jp.progression.core.commands.Command;   
import jp.progression.events.*;

class LoopCommand extends Command {
	
	private var _command:Command;
	private var _condition:Function;
	
	public function LoopCommand( command:Command, condition:Function, initObject:Object = null ) {
		super( _execute, _interrupt, initObject );
		
		_command = command;
		_condition = condition;
		
		timeOut = 0;
	}
	
	private function _execute():void{
		if ( _condition.apply( this ) ) {
			executeComplete();
		}
		
		_command.addEventListener( CommandEvent.COMMAND_COMPLETE, _commandComplete );
		_command.execute();
	}
	
	private function _commandComplete( e:CommandEvent ):void {
		_command.removeEventListener( CommandEvent.COMMAND_COMPLETE, _commandComplete );
		
		_execute();
	}
	
	private function _interrupt():void {
		if ( _command ) {
			_command.removeEventListener( CommandEvent.COMMAND_COMPLETE, _commandComplete );
			_command = null;
		}
		
		interruptComplete();
	}
	
	public override function clone():Command{
		return new LoopCommand( _command, _condition, this );
	}
}