import hype.extended.behavior.Swarm;
import hype.extended.color.ColorPool;
import hype.extended.rhythm.FilterCanvasRhythm;
import hype.framework.core.ObjectPool;
import hype.framework.core.TimeType;
import hype.framework.display.BitmapCanvas;
import hype.framework.rhythm.SimpleRhythm;
var myWidth = stage.stageWidth;
var myHeight = stage.stageHeight;
var bmc:BitmapCanvas = new BitmapCanvas(myWidth, myHeight);
addChild(bmc);
var clipContainer:Sprite = new Sprite();
var color:ColorPool = new ColorPool(
0x587b7C, 0x719b9E, 0x9FC1BE, 0xE0D9BB, 0xDACB94, 0xCABA88, 0xDABD55, 0xC49F32, 0xA97409
);
var pool:ObjectPool = new ObjectPool(MyCircle, 20);
function addNextClip(r:SimpleRhythm) {
if (pool.isFull) {
rhythm.stop();
} else {
pool.request();
}
}
var rhythm:SimpleRhythm = new SimpleRhythm(addNextClip);
rhythm.start(TimeType.TIME, 1000);
pool.onRequestObject = function(clip) {
clip.x = myWidth / 2;
clip.y = myHeight / 2;
// target Object, x and y, speed, rotation ease, twitch 20 = -10 to +10
var swarm:Swarm = new Swarm(clip, new Point(myWidth / 2, myHeight / 2), 10, 0.05, 20);
swarm.start();
color.colorChildren(clip);
clipContainer.addChild(clip);
}
bmc.startCapture(clipContainer, true);
var blur:FilterCanvasRhythm = new FilterCanvasRhythm([new BlurFilter(1.05, 1.05, 1)], bmc);
blur.start(TimeType.TIME, 40);