In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: 普通の時計 - Clock

Get Adobe Flash player
by kamip 31 Jul 2009
    Embed
// forked from kamip's forked from: 普通の時計 - Clock
// forked from rsakane's 普通の時計 - Clock
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	[SWF(width="465", height="465", frameRate="30", backgroundColor="0xF9F9F9")]
	public class Main extends Sprite
	{
		private var seconds:Vector.<Sprite> = new Vector.<Sprite>();
		private var minutes:Vector.<Sprite> = new Vector.<Sprite>();
		private var hours:Vector.<Sprite> = new Vector.<Sprite>();
		private var stf:TextField;
		private var mtf:TextField;
		private var htf:TextField;
		private var colors:Array = new Array(0xff58e5, 0x394cff, 0x00baff, 0x58ff58, 0xffff00, 0xff3939);

		public function Main()
		{
                        var int_a:int = 0;
			for (var degree:int = -90; degree < 270; degree += 6)
			{
                                var color:int = get_color(int_a);
				var second:Sprite = new Clock(color);
				second.rotation = degree;
				second.x = 230 + Math.cos(degree * Math.PI / 180) * 130;
				second.y = 230 + Math.sin(degree * Math.PI / 180) * 130;
				addChild(second);
				seconds.push(second);
				
				var minute:Sprite = new Clock(color);
				minute.rotation = degree;
				minute.x = 230 + Math.cos(degree * Math.PI / 180) * 110;
				minute.y = 230 + Math.sin(degree * Math.PI / 180) * 110;
				minute.scaleX = minute.scaleY = 0.9;
				addChild(minute);
				minutes.push(minute);
                                int_a = int_a + 1;
                        }
			var int_b:int = 0;
			for (degree = -90; degree < 270; degree += 15)
			{
                                var color_h:int = get_color(int_b);
				var hour:Sprite = new Clock(color_h);
				hour.rotation = degree;
				hour.x = 230 + Math.cos(degree * Math.PI / 180) * 90;
				hour.y = 230 + Math.sin(degree * Math.PI / 180) * 90;
				addChild(hour);
				hours.push(hour);
                                int_b = int_b + 1;
			}
			
			var date:Date = new Date();
			for (var i:int = 0; i <= date.seconds; i++)
			{
				seconds[i].alpha = 1.0;
			}
			
			for (i = 0; i <= date.minutes; i++)
			{
				minutes[i].alpha = 1.0;
			}
			
			for (i = 0; i <= date.hours; i++)
			{
				hours[i].alpha = 1.0;
			}
			
			htf = createTextField((String(date.hours).length == 1) ? "0" + String(date.hours) : String(date.hours), 41, 170, 160);
			addChild(htf);
			
			mtf = createTextField((String(date.minutes).length == 1) ? "0" + String(date.minutes) : String(date.minutes), 41, 210, 200);
			addChild(mtf);
			
			stf = createTextField((String(date.seconds).length == 1) ? "0" + String(date.seconds) : String(date.seconds), 41, 250, 240);
			addChild(stf);
			
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
                public function get_color(num:int):int
                {
                        var n:int = num % 6;
                        return colors[n];
                }
		private function onEnterFrame(event:Event):void
		{
			var date:Date = new Date();
			seconds[date.seconds].alpha = 1.0;
			minutes[date.minutes].alpha = 1.0;
			hours[date.hours].alpha = 1.0;
			
			stf.text = (String(date.seconds).length == 1) ? "0" + String(date.seconds) : String(date.seconds);

			var i:int;
			if (date.seconds == 0)
			{
				for (i = 1; i < 60; i++) seconds[i].alpha = 0.0;				
				mtf.text = (String(date.minutes).length == 1) ? "0" + String(date.minutes) : String(date.minutes);
			}
			
			if (date.minutes == 0)
			{
				for (i = 1; i < 60; i++) minutes[i].alpha = 0.0;
				htf.text = (String(date.hours).length == 1) ? "0" + String(date.hours) : String(date.hours);
			}
			
			if (date.hours == 0)
			{
				for (i = 1; i < 24; i++) hours[i].alpha = 0.0;
			}
		}
		
		private function createTextField(text:String, size:int, x:int, y:int):TextField
		{
			var tf:TextField = new TextField();
			tf.x = x, tf.y = y;
			tf.defaultTextFormat = new TextFormat("typwWriter_", size, 0x0, true);
			tf.text = text;
			tf.autoSize = "left";
			addChild(tf);
			
			return tf;
		}
	}
}

import flash.display.Sprite;

class Clock extends Sprite
{
	public function Clock(color:int)
	{
		graphics.beginFill(color);
		graphics.drawRect(0, 0, 10, 10);
		graphics.endFill();
		
		alpha = 0.0;
	}
 
}