雨を作ろうと思ったのに
package {
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.filters.GlowFilter;
[SWF(width = "465", height = "465", backgroundColor="#000000", frameRate=24)]
public class wonderfl extends Sprite
{
private var s:Shape;
public function wonderfl()
{
addEventListener(Event.ENTER_FRAME,generateCircle);
}
public var si:int;
public function generateCircle(e:Event):void{
//var glow:GlowFilter = new GlowFilter(0xffffff*0xffffff*Math.random(),.8,4,4,2,3);
var blur:BlurFilter = new BlurFilter(45,5,3);
if(si < 100){
s = new Shape();
}
var ar:Number = Math.random();
if(si%2 == 0){
s.graphics.beginFill(0xffffff*0xffffff*Math.random(),ar);
s.graphics.drawCircle(465/2+mouseX, 465/2+mouseY, 10);
s.graphics.endFill();
s.width = 5;
s.height = 5;
//s.filters = [glow];
s.filters = [blur];
addChild(s);
s.addEventListener(Event.ENTER_FRAME,snow);
si++;
}else{
s.graphics.beginFill(0xffffff*0xffffff*Math.random(),ar);
s.graphics.drawCircle(465/2-mouseX, 465/2-mouseY, 5);
s.graphics.endFill();
s.width = 5;
s.height = 5;
//s.filters = [glow];
s.filters = [blur];
addChild(s);
s.addEventListener(Event.ENTER_FRAME,snow);
si++;
}
}
public function snow(e:Event):void{
var snowObj:Shape = DisplayObject(e.target) as Shape;
var glow:GlowFilter = new GlowFilter(0xffffff,.8,4,4,2,4);
snowObj.filters = [glow];
var r:Number = Math.random()*0.1;
DisplayObject(e.target).x += 1;
DisplayObject(e.target).y += 1;
snowObj.alpha -= 0.01;
if(snowObj.alpha < 0.1 || DisplayObject(e.target).x > 470 || snowObj.y > 470 || DisplayObject(e.target).width > 100){
snowObj.alpha = Math.random();
DisplayObject(e.target).y = 0;
DisplayObject(e.target).x = mouseX;
DisplayObject(e.target).scaleX += r;
DisplayObject(e.target).scaleY += r;
s.graphics.clear();
s.graphics.beginFill(0xffffff,r*10);
s.graphics.drawCircle(465/2+mouseX, 465/2+mouseY, 2);
s.graphics.endFill();
s.width = 5;
s.height = 5;
}
}
}
}