forked from: マウスについてくる火
// write as3 code here..
package {
import flash.display.*;
import flash.events.Event;
import flash.geom.*;
import flash.filters.BlurFilter;
[SWF(width="320",height="320",backgroundColor="0x000000",frameRate="32")]
public class Take02 extends Sprite {
public var vFire:Vector.<Vector3D> = new Vector.<Vector3D>();
public function Take02():void {
var blur:BlurFilter=new BlurFilter(14,16);
filters=[blur];
addEventListener( Event.ENTER_FRAME, EnterFrame);
}
private function EnterFrame( event:Event ):void {
var p:Vector3D = new Vector3D();
if (vFire.length > 0) {
p.x = (vFire[vFire.length-1].x-mouseX)*0.85+mouseX;
p.y = (vFire[vFire.length-1].y-mouseY)*0.85+mouseY+5.5;
} else {
p.x=mouseX;
p.y=mouseY;
}
p.z=Math.random()*10-5;
p.w=1;
vFire.push(p);
while(numChildren > 0) {
removeChildAt(0);
}
while(vFire[0].w < 0.1) {
vFire.shift();
}
vFire.forEach(render);
}
private function render(item:Vector3D, index:int, vector:Vector.<Vector3D>):void {
vector[index].x = item.x+Math.random()*8-4;
vector[index].y = item.y-Math.random()*4-3;
var r:Number=Math.sqrt(item.w)*20;
var shape:Shape = new Shape();
shape.blendMode=BlendMode.ADD;
shape.graphics.beginFill(0xff1f00);
shape.graphics.drawCircle(vector[index].x, vector[index].y, r);
shape.z = item.z;
shape.alpha = Math.sqrt(item.w);
addChild( shape );
vector[index].w *= 0.85;
}
}
}