package{ import flash.display.Sprite; import mx.core.UIComponent; import flash.events.*; import mx.controls.Alert public class RooliAndur extends UIComponent{ [Bindable] public var n2it:Number=0; public var ring:Sprite=new Sprite(); public var t2pp:Sprite=new Sprite(); private var vananurk:Number=0; private var ringidearv:Number=0; public function RooliAndur(){ ring.graphics.beginFill(0XFF0000); ring.graphics.drawCircle(0, 0, 50); ring.graphics.endFill(); t2pp.graphics.beginFill(0X0000FF); t2pp.graphics.drawCircle(0, 0, 15); t2pp.graphics.endFill(); ring.addChild(t2pp); t2pp.x=40; addChild(ring); t2pp.addEventListener(MouseEvent.MOUSE_MOVE, hiirLiigub); } private function hiirLiigub(event:MouseEvent):void{ var dx:Number=event.stageX-this.x; var dy:Number=event.stageY-this.y; var nurk:Number=Math.atan2(dy, dx); ring.rotation=nurk*180/3.14; if(Math.abs(nurk)>1.5 && nurk*vananurk<0){ //Ületab nurga murdekoha if(nurk<0){ringidearv++;} else{ringidearv--;} } n2it=ringidearv*360+ring.rotation; vananurk=nurk; } } }