forked from: 満月 - Full moon
// forked from rsakane's 満月 - Full moon
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.GradientType;
import flash.events.Event;
import flash.filters.GlowFilter;
import flash.geom.Matrix;
import flash.geom.Point;
[SWF(width="465", height="465", frameRate="15", backgroundColor="0x0")]
public class Main extends Sprite
{
private var snow:Array = new Array();
private var filter:GlowFilter;
private var bd:BitmapData;
private var canvas:Sprite;
private var bitmap:Bitmap;
public function Main()
{
var matrix:Matrix = new Matrix();
matrix.createGradientBox(465, 465, 90 * Math.PI / 180);
graphics.beginGradientFill(GradientType.LINEAR, [0x0, 0x00009B, 0x0000FF], [1.0, 1.0, 1.0], [180, 250, 255], matrix);
graphics.drawRect(0, 0, 465, 465);
canvas = new Sprite();
for (var i:int = 0; i < Snow.SIZE; i++)
{
var s:Sprite = new Snow();
canvas.addChild(s);
snow.push(s);
}
var ms:Sprite = new Sprite();
matrix = new Matrix();
matrix.createGradientBox(100, 100, 45, 350, 100);
ms.graphics.beginGradientFill(GradientType.LINEAR, [0xFFCACBBB, 0xFFF2F3EE], [1.0, 1.0], [0, 230], matrix);
ms.graphics.drawCircle(350, 100, 100);
ms.graphics.endFill();
var moonbd:BitmapData = new BitmapData(465, 465, true, 0x00000000);
moonbd.draw(ms);
filter = new GlowFilter(0xEEEEEE, 1, 30, 30);
moonbd.applyFilter(moonbd, moonbd.rect, new Point(0, 0), filter);
var moon:Bitmap = new Bitmap(moonbd);
addChild(moon);
filter = new GlowFilter(0x8394E2);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
for (var i:int = 0; i < Snow.SIZE; i++)
{
snow[i].move();
}
bd = new BitmapData(465, 465, true, 0x00FF0000);
bd.draw(canvas);
bd.applyFilter(bd, bd.rect, new Point(0, 0), filter);
if (bitmap) removeChild(bitmap), bitmap = null;
bitmap = new Bitmap(bd);
addChild(bitmap);
}
}
}
class Snow extends flash.display.Sprite
{
public static var SIZE:int = 100;
public var dir:Boolean = (Math.random() <= 0.5) ? false : true;
public var speed:int = Math.random() * 2 + 1;
public function Snow()
{
draw();
x = Math.random() * 500 - 50;
y = Math.random() * 500 - 50;
alpha = Math.random();
}
private function draw():void
{
graphics.clear();
graphics.beginFill(0xFFFFFFFE);
graphics.drawCircle(5, 5, Math.random() * 2 + 1);
graphics.endFill();
}
public function move():void
{
y += speed;
if (y >= 470)
{
y = -5;
x = Math.random() * 465;
speed = Math.random() * 2 + 10;
draw();
}
}
}