package{ import flash.display.Sprite; public class Puu3 extends Sprite{ public function Puu3(){ joonista(); y=50; x=200; } public function joonistaOks(x1:Number, y1:Number, x2:Number, y2:Number):void{ graphics.moveTo(x1, y1); graphics.lineTo(x2, y2); var vektorx:Number=x2-x1; var vektory:Number=y2-y1; var ristvx:Number=vektory; var ristvy:Number=-vektorx; if(Math.sqrt(vektorx*vektorx+vektory*vektory)>5){ joonistaOks(x2, y2, x2+vektorx/1.5+ristvx/2, y2+vektory/1.5+ristvy/2); joonistaOks(x2, y2, x2+vektorx/2-ristvx/2, y2+vektory/2-ristvy/2); } } public function joonista():void{ graphics.clear(); graphics.lineStyle(1, 0, 1); //paksus, värv, nähtavus joonistaOks(100, 200, 110, 150); } } }