explode? - ばくはつ?
/**
* Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qH4s
*/
package
{
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(frameRate=60)]
public class FlashTest extends Sprite
{
private var bmpdata:BitmapData;
public function FlashTest()
{
this.graphics.beginFill(0);
this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
bmpdata=new BitmapData(stage.stageWidth,stage.stageHeight,false,0);
bmpdata.perlinNoise(bmpdata.width*.5,bmpdata.height*.5,3,Math.random()*0xFFFFFF,false,true);
stage.addEventListener(MouseEvent.MOUSE_DOWN,function(e:Event):void
{
bmpdata.perlinNoise(bmpdata.width*.5,bmpdata.height*.5,3,Math.random()*0xFFFFFF,false,true);
});
addEventListener(Event.ENTER_FRAME,function(e:Event):void
{
var sp:Sprite=new Sprite();
var x:int,y:int;
x=stage.mouseX+(Math.random()-.5)*50;
y=stage.mouseY+(Math.random()-.5)*50;
if(x<0)x=0;
else if(x>=bmpdata.width)x=bmpdata.width-1;
if(y<0)y=0;
else if(y>=bmpdata.height)y=bmpdata.height-1;
sp.x=x;
sp.y=y;
var r:int=Math.random()*15+5;
var cnt:int=0;
var onEnterFrame:Function=function(e:Event):void
{
cnt++;
sp.graphics.clear();
sp.graphics.beginFill(bmpdata.getPixel(x,y));
if(cnt<r)
{
sp.graphics.drawCircle(0,0,cnt);
}
else if(cnt<r*2)
{
sp.graphics.drawCircle(0,0,r);
sp.graphics.drawCircle(0,0,cnt-r);
}
else
{
sp.removeEventListener(Event.ENTER_FRAME,onEnterFrame);
removeChild(sp);
}
};
sp.addEventListener(Event.ENTER_FRAME,onEnterFrame);
addChild(sp);
});
}
}
}