forked from: 火の玉
/**
* Copyright wwbeyondww1 ( http://wonderfl.net/user/wwbeyondww1 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/30ra
*/
// forked from geko's 火の玉
// forked from KoheiTAKAMIYA's Flurryを作...れなかった
package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.ui.Mouse;
[SWF(frameRate="60")]
public class FlashTest extends Sprite {
private var bmp:Bitmap = new Bitmap();
private var flurry:Flurry;
private var i:Number = 0;
private var mouseDown:Boolean = false;
public function FlashTest() {
Mouse.hide();
bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000);
addChild(bmp);
addEventListener(Event.ENTER_FRAME, loop);
stage.addEventListener(MouseEvent.MOUSE_DOWN, function():void{mouseDown=true;});
stage.addEventListener(MouseEvent.MOUSE_UP, function():void{mouseDown=false;});
}
public function loop(event:Event):void{
i+=0.02;
flurry = new Flurry(Math.cos(Math.PI/2*i)*0.5, -1, Math.random()*0.05, -0.5, mouseDown ? 0x3366CC : 0xFF0000);
addChild(flurry);
flurry.x = mouseX;
flurry.y = mouseY;
flurry.addEventListener(Event.ENTER_FRAME, function update(event:Event):void{
var target:Flurry = event.target as Flurry;
target.update();
if(Math.min(Math.max(target.x, -3), stage.stageWidth+3) == target.x &&
Math.min(Math.max(target.y, -3), stage.stageHeight+3) == target.y
&& target.alpha > 0) return;
target.removeEventListener(Event.ENTER_FRAME, update);
removeChild(target);
target = null;
});
}
}
}
import flash.display.Shape;
import flash.display.BlendMode;
import flash.events.Event;
import flash.filters.BlurFilter;
class Flurry extends Shape{
private var filter:BlurFilter = new BlurFilter(10, 10, 3);
private var spout:Object = new Object();
private var wind:Object = new Object();
public function Flurry(spoutX:Number = 0, spoutY:Number = 0, windX:Number = 0, windY:Number = 0, color:uint = 0xCC6633):void{
blendMode = BlendMode.ADD;
filters = [filter];
spout.x = spoutX;
spout.y = spoutY;
wind.x = windX;
wind.y = windY;
graphics.beginFill(color);
for(var i:int =0;i<360;i++)
{
var t:Number=2*Math.PI*i/360;
var _x:Number=10*(16*Math.pow(Math.sin(t),3));
var _y:Number=-10*(13*Math.cos(t)-5*Math.cos(2*t)-2*Math.cos(3*t)-Math.cos(4*t));
graphics.drawCircle(_x, _y, 6);
}
graphics.endFill();
}
public function update():void{
spout.x += wind.x;
spout.y += wind.y;
x += spout.x;
y += spout.y;
alpha -= 0.05;
}
}