import hype.extended.behavior.Swarm;
import hype.extended.color.PixelColorist;
import hype.extended.layout.ShapeLayout;
import hype.extended.rhythm.FilterCanvasRhythm;
import hype.framework.behavior.BehaviorStore;
import hype.framework.core.ObjectPool;
import hype.framework.core.TimeType;
import hype.framework.display.BitmapCanvas;
import hype.framework.rhythm.SimpleRhythm;
MyShape.visible = false;
var myWidth = stage.stageWidth;
var myHeight = stage.stageHeight;
var bmc1:BitmapCanvas = new BitmapCanvas(myWidth, myHeight);
var bmc2:BitmapCanvas = new BitmapCanvas(myWidth, myHeight);
addChild(bmc2);
var clipContainer:Sprite = new Sprite();
var color:PixelColorist = new PixelColorist(MyImageColor, myWidth, myHeight);
var pool:ObjectPool = new ObjectPool(MyCircle, 25);
var layout:ShapeLayout = new ShapeLayout(MyShape);
var swarmPoint:Point;
function resetSwarm(r:SimpleRhythm) {
swarmPoint = layout.getNextPoint();
pool.activeSet.forEach(changeSwarmGoal);
}
function changeSwarmGoal(clip) {
var swarm:Swarm = BehaviorStore.retrieve(clip, “swarm”) as Swarm;
swarm.point = swarmPoint;
}
function colorClip(clip) {
color.colorChildren(clip);
}
function colorAll(r:SimpleRhythm) {
pool.activeSet.forEach(colorClip);
}
pool.onRequestObject = function(clip) {
clip.x = myWidth / 2;
clip.y = myHeight / 2;
clip.scaleX = clip.scaleY = 0.1 + ((Math.random() * 3) * 0.05);
// 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), 5, 0.02, 1);
swarm.start();
swarm.store(“swarm”);
colorClip(clip);
clipContainer.addChild(clip);
}
pool.requestAll();
bmc1.startCapture(clipContainer, true);
bmc2.startCapture(bmc1, true);
var blur:FilterCanvasRhythm = new FilterCanvasRhythm([new BlurFilter(3, 3, 1)], bmc1);
blur.start(TimeType.TIME, 1);
var resetPoint:SimpleRhythm = new SimpleRhythm(resetSwarm);
resetPoint.start(TimeType.TIME, 1000);
var resetColor:SimpleRhythm = new SimpleRhythm(colorAll);
resetColor.start(TimeType.TIME, 1);