AS Quiz #13

Today’s quiz is not multiple choice. Instead, your task is to draw a spiral using a recursive function.

Optionally you can alter your function to draw other types of spiral forms:

(You can view various solutions in the comments - as well as my solution at wonderfl)

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


  1. Nate
    Posted January 28, 2010 at 1:19 pm | Permalink

    Here’s my attempt:

    I may be cheating because I had to add in a const to keep from getting too many recursions if the number of degrees is large, and am passing some initializing variables into the function…

  2. Posted January 28, 2010 at 1:23 pm | Permalink

    nicely done… you could replace the const by adding a default var at the end of your arguments … max:int = 1000):void {…

  3. altschuler
    Posted January 28, 2010 at 3:16 pm | Permalink

    This is recursive or anything, it’s just fun to watch :-]

  4. altschuler
    Posted January 28, 2010 at 5:27 pm | Permalink

    was supposed to say “isn’t recursive” :)

  5. DieTapete
    Posted January 28, 2010 at 5:53 pm | Permalink

    This is my approach:

    var g:Graphics = graphics;
    g.lineStyle(1, 0×000000);
    g.moveTo(stage.stageWidth/2, stage.stageHeight/2);
    drawSpiral(0, 0);
    function drawSpiral(r, alpha){
    g.lineTo(stage.stageWidth/2+r*Math.cos(alpha), stage.stageHeight/2+r*Math.sin(alpha));
    if (r>100)


  6. Posted January 29, 2010 at 8:43 am | Permalink

    @altschuler - it’s nice to have a non-recursive version since I wasn’t planning on posting one.

    @DieTapete - Nicely done

Post a Comment

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