Circle Mouse Toy

var circles:Array = [];
for (var i:int = 0; i<30; i++){
	var c:Sprite = makeCircle();
	c.x = stage.stageWidth / 2;
	c.y = stage.stageHeight / 2;
	c.scaleX = 1 + i/2;
	c.scaleY = 0.5 + i/4;
	addChild(c);
	circles.push(c);
}
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
	circles[0].y += (mouseY - circles[0].y) / 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;
	}
}
function makeCircle():Sprite{
	var s:Sprite = new Sprite();
	with(s.graphics){
		lineStyle(0,0x000000);
		drawCircle(0,0,10);
	}
	return s;
}

This morning I woke up with a vision of this simple mouse toy in my head. I decided I might as well code it up… I may do more simple things like this in the next few days, it’s relaxing.

Mouse Toy – wonderfl build flash online

5 comments

  1. I’ve been playing a lot with your code. Thanks.

    It’s really fun if you just add a random color for the circle line.

Leave a Reply

Your email address will not be published. Required fields are marked *