FlashDevelopとFlex SDK3でデジタルクロック作成 その2

FlashDevelopとFlex SDK3でデジタルクロッククラスをカスタマイズしてみました。
Tweenerを使用してビヨ~ンと時分秒が入れ替わるようになっています。

flash on 2009-5-9 – wonderfl build flash online

ソースは以下。もっとスマートな実現方法を教えてもらいたいです。

package
{
	import flash.display.*;
	import flash.events.*;
	import flash.text.*;
	import flash.utils.*;
	import caurina.transitions.properties.*;
	import caurina.transitions.*;

	/**
	 * ...
	 * @author iweek
	 */

	public class DigitalClockTween extends Sprite
	{
		//[Embed(source = 'font/mplus-1mn-medium.ttf', fontName = 'mplus', mimeType = 'application/x-font')]
		//private var myfont:Class;
		private var upperHour:TextField = new TextField();
		private var lowerHour:TextField = new TextField();
		private var upperMin:TextField = new TextField();
		private var lowerMin:TextField = new TextField();
		private var upperSec:TextField = new TextField();
		private var lowerSec:TextField = new TextField();
		private var preSec:int;
		private var xPosition:int;
		private var yPosition:int;

		public function DigitalClockTween(font:String = "arial bold",size:Number = 18, color:Number = 0x000000 ):void
		{
			addEventListener(Event.ENTER_FRAME, clockShowTimer);
			iniTextField(upperHour, font, size, color);
			iniTextField(lowerHour, font, size, color);
			iniTextField(upperMin, font, size, color);
			iniTextField(lowerMin, font, size, color);
			iniTextField(upperSec, font, size, color);
			iniTextField(lowerSec, font, size, color);

		}
		private function clockShowTimer(event:Event):void
		{
			var now:Date = new Date();
			var hour:int = now.getHours();
			var min:int = now.getMinutes();
			var sec:int = now.getSeconds();  

			if (preSec != sec)
			{
				lowerSec.alpha = 0;
				lowerSec.y = lowerSec.y - 10;
				upperHour.text = String(int(hour / 10));
				lowerHour.text = String(int(hour % 10));
				upperMin.text = ":" + String(int(min / 10));
				lowerMin.text = String(int(min % 10));
				upperSec.text = ":" + String(int(sec / 10));
				lowerSec.text = String(int(sec % 10));
				Tweener.addTween(lowerSec, { time:0.5, y:yPosition, alpha:1.0, transition:"easeOutBounce" } );
				if (sec % 10 == 0)
				{
					upperSec.alpha = 0;
					upperSec.y = upperSec.y - 10;
					Tweener.addTween(upperSec, { time:0.5, y:yPosition, alpha:1.0, transition:"easeOutBounce" } );
				}
				if (sec == 0)
				{
					lowerMin.alpha = 0;
					lowerMin.y = upperSec.y - 10;
					Tweener.addTween(lowerMin, { time:0.5, y:yPosition, alpha:1.0, transition:"easeOutBounce" } );
					if (min % 10 == 0)
					{
						upperMin.alpha = 0;
						upperMin.y = upperMin.y - 10;
						Tweener.addTween(upperMin, { time:0.5, y:yPosition, alpha:1.0, transition:"easeOutBounce" } );
					}
					if (min == 0)
					{
						lowerHour.alpha = 0;
						lowerHour.y = lowerHour.y - 10;
						Tweener.addTween(lowerHour, { time:0.5, y:yPosition, alpha:1.0, transition:"easeOutBounce" } );
					}
					if (hour % 10 == 0)
					{
						upperHour.alpha = 0;
						upperHour.y = upperHour.y - 10;
						Tweener.addTween(upperHour, { time:0.5, y:yPosition, alpha:1.0, transition:"easeOutBounce" } );
					}
				}
			}

			upperHour.x = 0;
			lowerHour.x = upperHour.x + upperHour.width;
			upperMin.x = lowerHour.x + lowerHour.width;
			lowerMin.x = upperMin.x + upperMin.width;
			upperSec.x = lowerMin.x + lowerMin.width;
			lowerSec.x = upperSec.x + upperSec.width;

			preSec = now.getSeconds();
		}

		private function iniTextField(textField:TextField,font:String,size:Number,color:Number):void
		{
			textField.defaultTextFormat=new TextFormat(font, size, color);
			textField.autoSize = TextFieldAutoSize.LEFT;
			textField.selectable = false;
			//textField.antiAliasType = "advanced";
			//textField.embedFonts = true;
			//textField.alpha = 0;
			addChild(textField);
		}
	}
}
rss