forked from: Rotation math

by bradsedito forked from Rotation math (diff: 1)
♥0 | Line 27 | Modified 2012-07-23 04:42:07 | MIT License
play

ActionScript3 source code

/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/o0rW
 */

// forked from Good's Rotation math
// forked from makc3d's Clock
package  {
    import flash.text.TextFormat;
    import flash.text.TextField;
    import flash.display.Sprite;
    import flash.events.Event;
    [SWF (width=465, height=465)]
    public class Clock extends Sprite {
        public function Clock () {
            super (); 
            x = y = 465 / 2; 
            //rotation = -90;
            
            var tf:TextField = new TextField();
            tf.autoSize = 'left';
            tf.x = tf.y = -200;
            addChild(tf);
            tf.defaultTextFormat = new TextFormat('arial', 11, 0x333333, true);
            
            
            var a:int=0, r:Number=2;
            addEventListener (Event.ENTER_FRAME, function (e:Event):void {
                
                r+=.06;
                a += a<360 ? 3 : -360;
                var rad:Number = a * Math.PI / 180;
               // graphics.clear (); 
                graphics.lineStyle (2);
                graphics.lineTo (r * Math.cos (rad), r * Math.sin (rad)); 
                //graphics.moveTo (0, 0);
                
                tf.text = a+'\n'+rad;
            });
        }

    }
}