package{ import flash.display.Sprite; public class Puu2 extends Sprite{ public function Puu2(){ 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+ristvx/2, y2+ristvy/2); joonistaOks(x2, y2, x2-ristvx/2, y2-ristvy/2); } } public function joonista():void{ graphics.clear(); graphics.lineStyle(1, 0, 1); //paksus, värv, nähtavus joonistaOks(100, 200, 110, 150); } } }