forked from: マウスについてくる火
// forked from mogera's マウスについてくる火
// write as3 code here..
package
{
import flash.display.*;
import flash.events.Event;
import flash.geom.*;
[SWF(width="320", height="320", backgroundColor="0x000000", frameRate="60")]
public class Fire extends Sprite
{
public function Fire() : void
{
addEventListener( Event.ENTER_FRAME, EnterFrame) ;
}
private function EnterFrame( event:Event ) : void
{
var p:Point = new Point();
var r:int = 20
p.x = mouseX + Math.random() * r - (r/2);
p.y = mouseY;
addChild( new Sphere(p) );
}
}
}
import flash.events.Event;
import flash.display.*;
import flash.geom.*;
import flash.filters.BlurFilter;
class Sphere extends Sprite
{
private var _l:int = 30;
public function Sphere(point:Point) : void
{
blendMode = BlendMode.SCREEN;
x = point.x;
y = point.y;
var shape:Shape = new Shape();
var r:Number = 30//Math.random() * 30 + 15;
shape.graphics.beginFill(0x0000FF);
shape.graphics.drawCircle(0, 0, r);
shape.graphics.endFill();
shape.graphics.beginFill(0x66FFFF);
shape.graphics.drawCircle(0, r*0.4, r*0.5);
shape.graphics.endFill();
shape.scaleY = 1.2;
addChild( shape );
var blur : BlurFilter = new BlurFilter(24,24);
filters = [blur];
addEventListener( Event.ENTER_FRAME, EnterFrame);
}
public function EnterFrame(event:Event) : void
{
this.alpha -= 0.02;
scaleY *= 0.97;
scaleX *= 0.97;
this.y -= 5;
_l--;
if( _l < 0 )
{
removeEventListener( Event.ENTER_FRAME, EnterFrame);
// さようなら
if( parent )
{
parent.removeChild( this );
}
}
}
}