// 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俺俺コマンド
// write as3 code here..
package{
import flash.display.*;
import flash.events.*;
import jp.progression.commands.*;
import jp.progression.events.*;
public class NoiseTest extends MovieClip{
private var _bitmapdata:BitmapData;
private var _bitmap:Bitmap;
public function NoiseTest(){
var sList:SerialList = new SerialList();
var loopList:SerialList = new SerialList();
_bitmapdata = new BitmapData(stage.stageWidth,stage.stageHeight,true);
_bitmap = new Bitmap(_bitmapdata);
this.addChild(_bitmap);
loopList.addCommand(
function():void{addEventListener(Event.ENTER_FRAME,enterFrameHandler);},
new Wait(3000),
function():void{removeEventListener(Event.ENTER_FRAME,enterFrameHandler);},
function():void{addEventListener(Event.ENTER_FRAME,enterFrameHandler2);},
new Wait(3000),
function():void{removeEventListener(Event.ENTER_FRAME,enterFrameHandler2);},
function():void{addEventListener(Event.ENTER_FRAME,enterFrameHandler3);},
new Wait(3000),
function():void{removeEventListener(Event.ENTER_FRAME,enterFrameHandler3);}
);
sList.addCommand(new LoopCommand(loopList));
sList.execute();
}
private function enterFrameHandler(e:Event):void{
var low:Number=Math.random()*64;
var high:Number=Math.random()*128+128;
_bitmapdata.noise(1,low,high,1|1|1,false);
}
private function enterFrameHandler2(e:Event):void{
var low:Number=Math.random()*64;
var high:Number=Math.random()*128+128;
_bitmapdata.noise(1,low,high,4|4|4,false);
}
private function enterFrameHandler3(e:Event):void{
var low:Number=Math.random()*64;
var high:Number=Math.random()*128+128;
_bitmapdata.noise(1,low,high,2|2|1,false);
}
}
}
import jp.progression.commands.*;
import jp.progression.core.commands.Command;
import jp.progression.events.*;
class LoopCommand extends Command{
private var _command:Command;
public function LoopCommand(command:Command,initObject:Object = null){
super( _execute, _interrupt, initObject );
_command = command;
}
private function _execute():void{
_command.addEventListener(CommandEvent.COMMAND_COMPLETE,commandComp);
_command.execute();
executeComplete();
}
private function commandComp(e:CommandEvent):void{
_command.execute();
}
private function _interrupt():void{
_command.removeEventListener(CommandEvent.COMMAND_COMPLETE,commandComp);
interruptComplete();
}
public override function clone():Command{
return new LoopCommand(_command);
}
}