砂
...
@author ue
/**
* Copyright _ueueueueue ( http://wonderfl.net/user/_ueueueueue )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pM8Y
*/
package
{
import flash.display.*;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.geom.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.Timer;
[SWF(width=465,height=465,backgroundColor=0x0,frameRate=60)]
/**
* ...
* @author ue
*/
public class Main extends Sprite
{
private static const NUM:int = 1000;
private var container:Sprite;
private var balls:Array;
private var point:Point;
private var timer:Timer;
private var canvas:BitmapData;
public function Main():void
{
canvas = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x0);
var bmp:Bitmap = addChild(new Bitmap(canvas)) as Bitmap;
bmp.blendMode = BlendMode.ADD;
draw();
point = new Point(Math.random()*stage.stageWidth,Math.random()*stage.stageHeight);
timer = new Timer(200, 0);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
addEventListener(Event.ENTER_FRAME, update);
stage.addEventListener(MouseEvent.CLICK, draw);
}
private function draw(e:Event = null):void
{
container = new Sprite();
canvas.fillRect(canvas.rect, 0x0);
balls = new Array();
var i:int;
for (i = 0; i < NUM; i++)
{
var ball:Sprite = new Sprite();
ball.graphics.beginFill(0xFFFFFF);
ball.graphics.drawCircle(0, 0, 0.5);
ball.graphics.endFill();
ball.x = Math.random() * stage.stageWidth;
ball.y = Math.random() * stage.stageHeight;
container.addChild(ball);
balls.push(ball);
}
}
private function onTimer(e:TimerEvent):void
{
point.x = stage.stageWidth * Math.random();
point.y = stage.stageHeight * Math.random();
}
private function update(e:Event):void
{
var i:int;
for (i = 0; i < balls.length; i++)
{
var ball:Sprite = balls[i];
if (i == 0)
{
ball.x += (point.x - ball.x) / 4;
ball.y += (point.y - ball.y) / 4;
}
else
{
ball.x += (balls[i - 1].x -ball.x) / 4;
ball.y += (balls[i - 1].y -ball.y) / 4;
}
}
canvas.lock();
canvas.draw(container);
canvas.unlock();
}
}
}