Forked from: northprint's Bitmapdata.perlinNoise diff:13 forked from: Bitmapdata.perlinNoise コマンドのループby俺俺コマンド perlinNoise版 northprint forked:0favorite:0lines:81license : All rights reserved modified : 2008-12-26 16:58:19 Embed Tweet // forked from northprint's Bitmapdata.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 ); //コマンドを止めるボタンを設置 var stopButton:Sprite = new Sprite(); stopButton.graphics.beginFill(0xff0000); stopButton.graphics.drawRect(0,0,100,100); stopButton.graphics.endFill(); stopButton.buttonMode = true; addChild(stopButton); addEventListener(MouseEvent.CLICK,_stopClick); 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 _stopClick( e:MouseEvent):void{ _loop.interrupt(); } 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 ); } } Code Fullscreen Preview Fullscreen Command CommandEvent.COMMAND_COMPLETE perlinNoise interrupt removeEventListener timeOut CommandEvent apply buttonMode interruptComplete executeComplete execute Wait SerialList addEventListener clone MouseEvent.CLICK drawRect MouseEvent beginFill