flash on 2010-6-4

by namagome
♥0 | Line 95 | Modified 2010-07-20 16:20:53 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.events.Event;
    import flash.text.*;
    
    [SWF (width=465, height=465, FPS=24)]
    
    public class timeField extends Sprite {
        public function timeField() {
            var Center:int = 465/2
            
            var tf:TextFormat = new TextFormat();
            tf.size = 32;
            tf.align = TextFormatAlign.CENTER;    
            var fld:TextField = new TextField();
            fld.background = true;
            //fld.backgroundColor = 0x000000;
            //fld.textColor = 0xFFFFFF;
            fld.y = 12;
            fld.width = 465;
            fld.height = 80;
            fld.defaultTextFormat = tf;
            addChild(fld);
            
            var S_hand:MovieClip= new MovieClip();
            addChild(S_hand);
            
            addEventListener(Event.ENTER_FRAME, Watch);
            function Watch(e:Event):void {
                
                var a_date:Date = new Date();
                var h:Number = a_date.hours;
                var m:Number = a_date.minutes;
                var s:Number = a_date.seconds;
                var ms:Number = a_date.milliseconds;
                var H:String = String(h + 100).substring(1);
                var M:String = String(m + 100).substring(1);
                var S:String = String(s + 100).substring(1);
                var MS:String = String(ms / (1000/24) + 100).substring(1,3);
                
                fld.text = H + ":" + M + ":" + S + ":" + MS + "\n" + "(00000)";
                
                S_hand.x = S_hand.y = Center;
                S_hand.rotation = -90;
                var roll:Number = ms / 1000 * Math.PI * 2 / 6;
                S_hand.graphics.clear ();
                S_hand.graphics.lineStyle (5);
                S_hand.graphics.lineTo (120 * Math.cos (roll), 120 * Math.sin (roll));
                S_hand.graphics.moveTo (0, 0);
                
            }
            
            var START_BUTTON:SimpleButton = new SimpleButton();
            
            
            var BG:Sprite = new Sprite();
            BG.x = BG.y = Center;
            BG.rotation = -90;
            BG.graphics.beginFill(0xCCDDFF);
            BG.graphics.lineStyle (2,0x0000FF);
            BG.graphics.drawCircle(0, 0, 130);
            BG.graphics.endFill();
            
            BG.graphics.lineStyle (2,0x0000FF);
            BG.graphics.moveTo(130 * Math.cos( 30* Math.PI / 180), 130 * Math.sin( 30* Math.PI / 180));
            BG.graphics.lineTo(130 * Math.cos(210* Math.PI / 180), 130 * Math.sin(210* Math.PI / 180));
            BG.graphics.moveTo(130 * Math.cos( 90* Math.PI / 180), 130 * Math.sin( 90* Math.PI / 180));
            BG.graphics.lineTo(130 * Math.cos(270* Math.PI / 180), 130 * Math.sin(270* Math.PI / 180));
            BG.graphics.moveTo(130 * Math.cos(150* Math.PI / 180), 130 * Math.sin(150* Math.PI / 180));
            BG.graphics.lineTo(130 * Math.cos(330* Math.PI / 180), 130 * Math.sin(330* Math.PI / 180));
            
            BG.graphics.beginFill(0xCCDDFF);
            BG.graphics.lineStyle();
            BG.graphics.drawCircle(0, 0, 130 * 0.95);
            BG.graphics.endFill();
            
            BG.graphics.lineStyle (3,0x0000FF);
            BG.graphics.moveTo(130,0);
            BG.graphics.lineTo(-130,0);
            BG.graphics.moveTo(130 * Math.cos( 60* Math.PI / 180), 130 * Math.sin( 60* Math.PI / 180));
            BG.graphics.lineTo(130 * Math.cos(240* Math.PI / 180), 130 * Math.sin(240* Math.PI / 180));
            BG.graphics.moveTo(130 * Math.cos(120* Math.PI / 180), 130 * Math.sin(120* Math.PI / 180));
            BG.graphics.lineTo(130 * Math.cos(300* Math.PI / 180), 130 * Math.sin(300* Math.PI / 180));
            
            BG.graphics.beginFill(0xCCDDFF);
            BG.graphics.lineStyle();
            BG.graphics.drawCircle(0, 0, 130 * 0.925);
            BG.graphics.endFill();
            
            BG.graphics.beginFill(0x0000FF,0.1);
            BG.graphics.moveTo(0, 0)
            for( var d:uint; d< 61; d++ ){
                var rad_d:Number = d* Math.PI / 180;
                BG.graphics.lineTo( 130 * Math.cos( rad_d), 130 * Math.sin( rad_d));}
            BG.graphics.endFill();
            BG.graphics.beginFill(0x0000FF,0.1);
            BG.graphics.moveTo(0, 0)
            for( var e:uint = 120;e < 181; e++ ){
                var rad_e:Number = e * Math.PI / 180;
                BG.graphics.lineTo( 130 * Math.cos( rad_e ), 130 * Math.sin( rad_e ));}
            BG.graphics.endFill();
            BG.graphics.beginFill(0x0000FF,0.1);
            BG.graphics.moveTo(0, 0)
            for( var f:uint = 240;f < 301; f++ ){
                var rad_f:Number = f * Math.PI / 180;
                BG.graphics.lineTo( 130 * Math.cos( rad_f ), 130 * Math.sin( rad_f ));}
            BG.graphics.endFill();
            
            addChild(BG);
            setChildIndex(BG,0)
        }
    }
}