煙も
// 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="20")]
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();
p.x = mouseX + Math.random() * 100- 50;
p.y = mouseY + 0;
var r:Number = Math.random() * 30 + 15;
addChild( new Sphere(p,0xaaaaaa,0.1,r) );
var p2:Point = new Point();
p2.x = mouseX + Math.random() * 10 - 5;
p2.y = mouseY + Math.random() * 10 - 5;
var r2:Number = 30
var s:Sphere = new Sphere(p2,0xff0f00,1,r2);
s.blendMode = BlendMode.ADD;
addChild( s );
}
}
}
import flash.events.Event;
import flash.display.*;
import flash.geom.*;
import flash.filters.BlurFilter;
class Sphere extends Sprite
{
private var counter:int = 0;
public function Sphere(point:Point, color:uint, al:Number,r:Number) : void
{
//blendMode = BlendMode.ADD;
x = point.x;
y = point.y;
var shape:Shape = new Shape();
shape.graphics.beginFill(color,al);
shape.graphics.drawCircle(0, 0, r);
addChild( shape );
var blur : BlurFilter = new BlurFilter(16,16);
filters = [blur];
addEventListener( Event.ENTER_FRAME, EnterFrame);
}
public function EnterFrame(event:Event) : void
{
scaleY *= 0.95;
scaleX *= 0.95;
//alpha = scaleY;
this.y -= 3;
if( scaleX <= 0.1 )
{
removeEventListener( Event.ENTER_FRAME, EnterFrame);
// さようなら
if( parent )
{
parent.removeChild( this );
}
}
}
}