Circle Mouse Toy

Actionscript:
  1. var circles:Array = [];
  2. for (var i:int = 0; i<30; i++){
  3.     var c:Sprite = makeCircle();
  4.     c.x = stage.stageWidth / 2;
  5.     c.y = stage.stageHeight / 2;
  6.     c.scaleX = 1 + i/2;
  7.     c.scaleY = 0.5 + i/4;
  8.     addChild(c);
  9.     circles.push(c);
  10. }
  11. addEventListener(Event.ENTER_FRAME, onLoop);
  12. function onLoop(evt:Event):void {
  13.     circles[0].y += (mouseY - circles[0].y) / 4;
  14.     for (var i:int = 1; i<circles.length; i++){
  15.         var pre:Sprite = circles[i - 1];
  16.         circles[i].y += (pre.y - circles[i].y) / 4;
  17.     }
  18. }
  19. function makeCircle():Sprite{
  20.     var s:Sprite = new Sprite();
  21.     with(s.graphics){
  22.         lineStyle(0,0x000000);
  23.         drawCircle(0,0,10);
  24.     }
  25.     return s;
  26. }

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.

This entry was posted in Graphics, misc, motion and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. Posted April 25, 2010 at 2:21 am | Permalink

    At least, crazy. hehehehe

  2. Posted April 26, 2010 at 12:40 am | Permalink

    Very cool :-)

  3. DieTapete
    Posted April 28, 2010 at 2:38 am | Permalink

    cool and simple idea

  4. Posted May 20, 2010 at 12:05 am | Permalink

    I forked it twice )

  5. Adrien
    Posted June 1, 2010 at 2:33 am | Permalink

    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.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*