forked from: forked from: Mouse Toy DrawRect
/**
* Copyright alexnotkin ( http://wonderfl.net/user/alexnotkin )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zDt3
*/
// forked from smakhtin's forked from: Mouse Toy
// forked from shapevent's Mouse Toy
package {
import flash.display.*;
import flash.events.*;
import frocessing.color.ColorHSV;
public class MouseToy extends MovieClip {
private var circles:Array;
private var hsv:ColorHSV;
private var color:uint;
public function MouseToy(){
// init
circles = [];
hsv = new ColorHSV();
hsv.h = color;
for (var i:int = 0; i<60; i++){
var c:Sprite = makeCircle();
c.x = stage.stageWidth / 2;
c.y = stage.stageHeight / 2;
c.scaleX = Math.random()*0.5 + i/2;
c.scaleY = 0.5 + i/4;
addChild(c);
circles.push(c);
}
addEventListener(Event.ENTER_FRAME, onLoop);
}
// private methods
private function onLoop(evt:Event):void {
circles[0].y += (mouseY - circles[0].y) / 4;
circles[0].x += (mouseX - circles[0].x) /4;
for (var i:int = 1; i<circles.length; i++){
var pre:Sprite = circles[i - 1];
circles[i].y += (pre.y - circles[i].y) / 4;
circles[i].x += (pre.x - circles[i].x) / 4;
}
}
private function makeCircle():Sprite{
var s:Sprite = new Sprite();
with(s.graphics){
lineStyle(0.6,hsv.value);
drawRect(0, 0, 10, 10);
color+=2;
hsv.h = color;
}
return s;
}
}
}