As Quiz #13 solution Move your mouse left and right shapevent forked:0favorite:1lines:25license : MIT License modified : 2010-01-30 00:51:06 Embed Tweet // Move your mouse left and right package { import flash.display.Sprite; import flash.events.Event; public class RecursiveSpiral extends Sprite { [SWF(width = 500, height = 500)] public function RecursiveSpiral() { ///////////////////////// scaleX = scaleY = 0.5; x = stage.stageWidth / 2; y = stage.stageHeight / 2; addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { graphics.clear(); graphics.lineStyle(0,0); spiral(mouseX, 200); } function spiral(step:Number= 10, maxIter:Number=100, x:Number=0, y:Number=0, inc:Number = 1):void{ if (inc < maxIter){ var theta:Number = inc * step * Math.PI / 180; graphics.lineTo(x, y); spiral(step, maxIter, x + theta * Math.cos(theta), y + theta * Math.sin(theta), inc + 1); } } ///////////////////////// } } } Code Fullscreen Preview Fullscreen alexnotkin Graphics, recursion, recusive, spiral scaleY scaleX mouseX addEventListener Math.cos Event.ENTER_FRAME Math.sin Math.PI Event Sprite Number