Tag Archives: sprial

Draw Spiral

Actionscript:
  1. stage.frameRate = 30;
  2. var xp:Number = 0;
  3. var yp:Number = 0;
  4. var counter:Number = 0;
  5. graphics.lineStyle(0,0x999999);
  6. graphics.moveTo(200,200);
  7. addEventListener(Event.ENTER_FRAME, onLoop);
  8. function onLoop(evt:Event):void {
  9.     for (var i:int = 0; i <20; i++) {
  10.         counter += .05;
  11.         xp=200 + counter * Math.cos(counter);
  12.         yp=200 + counter * Math.sin(counter);
  13.         graphics.lineTo(xp, yp);
  14.     }
  15.     if (counter> 400) {
  16.         removeEventListener(Event.ENTER_FRAME, onLoop);
  17.     }
  18. }

Draws a spiral over time.

Posted in Graphics, motion | Also tagged , | Leave a comment