forked from: ポタポタ
// forked from knd's ポタポタ
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.ColorTransform;
public class TestBubble extends Sprite
{
private const LW:Number = 16.0;//Line Width
private var pColor:uint = 0xffffff;
private var lColor:uint = 0x3f3f3f;
private var fColor:uint = 0xc0c0c0;
private var pointGra:Sprite;
private var fillGra:Sprite;
private var lineGra:Sprite;
private var bm:Bitmap;
public function TestBubble()
{
bm = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xffffffff));
addChild(bm);
pointGra = new Sprite();
fillGra = new Sprite();
lineGra = new Sprite();
addChild(lineGra);
addChild(fillGra);
addChild(pointGra);
new myTimer(1000).setRepeatAndGo(timer);
addEventListener(Event.ENTER_FRAME, loop);
}
private function timer(e:TimerEvent):void
{
bm.bitmapData.draw(this);
lineGra.graphics.clear();
fillGra.graphics.clear();
pointGra.graphics.clear();
var c:uint = 0x1000000 * Math.random() | 0;
lColor = c;
fColor = 0x808080 + ((c & 0xfefefe) >> 1);
pColor = 0xc0c0c0 + ((c & 0xfcfcfc) >> 2);
}
private function loop(e:Event):void
{
var _x:Number = stage.stageWidth * Math.random();
var _y:Number = stage.stageHeight * Math.random();
var _r:Number = LW + 2 * LW * Math.random();
lineGra.graphics.beginFill(lColor);
lineGra.graphics.drawCircle(_x, _y, _r + LW);
fillGra.graphics.beginFill(fColor);
fillGra.graphics.drawCircle(_x, _y, _r);
pointGra.graphics.beginFill(pColor);
pointGra.graphics.drawCircle(_x, _y, _r - LW);
_x += 2 * _r * (Math.random()-0.5);
_y += 2 * _r * (Math.random()-0.5);
_r *= 0.8 + 0.4 * Math.random();
lineGra.graphics.beginFill(lColor);
lineGra.graphics.drawCircle(_x, _y, _r + LW);
fillGra.graphics.beginFill(fColor);
fillGra.graphics.drawCircle(_x, _y, _r);
pointGra.graphics.beginFill(pColor);
pointGra.graphics.drawCircle(_x, _y, _r - LW);
}
}
}
import flash.events.TimerEvent;
import flash.utils.Timer;
internal class myTimer extends Timer
{
public function myTimer(delay:Number, repeatCount:int = 0)
{
super(delay, repeatCount);
}
public function setRepeatAndGo(listener:Function):void
{
super.addEventListener(TimerEvent.TIMER, listener);
super.start();
}
}