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: いろいろFontClock

そういえば、フォントのリストを取得できるのね。

太ったフォント、痩せたフォント、読めないフォント。
いつのまにかたくさん入ってる。

すぐに忘れちゃってごめんね。
こうやってたまには思い出すことにするよ。

Font class
http://help.adobe.com/ja_JP/AS3LCR/Flash_10.0/flash/text/Font.html
*
Get Adobe Flash player
by paquo 11 Dec 2009
/**
 * Copyright paquo ( http://wonderfl.net/user/paquo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4Eyx
 */

// forked from umhr's いろいろFontClock
/*
そういえば、フォントのリストを取得できるのね。

太ったフォント、痩せたフォント、読めないフォント。
いつのまにかたくさん入ってる。

すぐに忘れちゃってごめんね。
こうやってたまには思い出すことにするよ。

Font class
http://help.adobe.com/ja_JP/AS3LCR/Flash_10.0/flash/text/Font.html
* */

package 
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.Font;
	import flash.utils.Timer;
	/**
	 * ...
	 * @author umhr
	 */
	[SWF(backgroundColor="0xFDFddd")]
	public class Main extends Sprite {
		private var fonts:Array;
		public function Main():void {
			//fontのリストを取得
			fonts = Font.enumerateFonts(true);
			//1秒に一度onTimerを呼び出す。
			var timer:Timer = new Timer(1000,0);
			timer.addEventListener(TimerEvent.TIMER,onTimer);
			timer.start();
		}
		private function onTimer(e:TimerEvent):void{
			while (this.numChildren > 0) {
				this.removeChildAt(0);
			}
			
			var canvas:Sprite = new Sprite();
			
			//時刻を取得
			var date:Date = new Date();
			var times:Array = [String(date.getHours()),":",String(date.getMinutes()),"'",String(date.getSeconds()),".",String(date.getMilliseconds())];
			
			//ランダムを使って、フォントを設定。
			for (var i:int = 0; i < times.length; i++) {
				var tf:TextField = new TextField();
				tf.text = times[i];
				var fontNumber:int = Math.floor(fonts.length*Math.random());
				tf.setTextFormat(new TextFormat(fonts[fontNumber].fontName,56));
				tf.autoSize = "right";
				tf.selectable = false;
				tf.textColor = 0x42261C;
				tf.x = canvas.width;
				canvas.addChild(tf);
			}
			
			//画面真ん中に
			canvas.x = 	(stage.stageWidth-canvas.width)/2;
			canvas.y = 	(stage.stageHeight-canvas.height)/2;
			this.addChild(canvas);
		}
	}
}