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

万年カレンダー

万年カレンダー
5秒おきに翌月のカレンダーになります。
どの月も31日まであるんで誰かforkお願いします。
Get Adobe Flash player
by cda244 06 Mar 2009
/*
万年カレンダー
5秒おきに翌月のカレンダーになります。
どの月も31日まであるんで誰かforkお願いします。

*/

package
{
	
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import caurina.transitions.Tweener;
	
	[SWF(width="400", height="300", backgroundColor="0xFFFFFF", frameRate="30")]

	public class Main extends MovieClip
	{
		private const CAL1:String="                      1  2  3  4  5  6  7\n";
		private const CAL2:String=" 1  2  3  4  5  6  7  8  9 10 11 12 13 14\n";
		private const CAL3:String=" 8  9 10 11 12 13 14 15 16 17 18 19 20 21\n";
		private const CAL4:String="15 16 17 18 19 20 21 22 23 24 25 26 27 28\n";
		private const CAL5:String="22 23 24 25 26 27 28 29 30 31\n";
		private const CAL6:String="29 30 31\n";
		
		private var calW:uint;
		private var calH:uint;
		private var calBlockW:Number;
		private var calGoalX:Number;
		private var date_txt:TextField = new TextField();
		private var cal_txt:TextField = new TextField();
		private var day_mc:MovieClip = new MovieClip();
		private var tFormat:TextFormat = new TextFormat("_等幅", 16);
		private var calTimer:Timer=new Timer(5000);
		private var date:Date;
		
		
		public function Main():void
		{
			tFormat.leading=3;

			date_txt.defaultTextFormat = tFormat;
			date_txt.width = 400;
			date_txt.x = 50;
			date_txt.y = 50;
			
			cal_txt.defaultTextFormat = tFormat;
			cal_txt.text = CAL1 + CAL2 + CAL3 + CAL4 + CAL5 + CAL6;
			cal_txt.x = -400;
			cal_txt.y = 100;
			cal_txt.width = 400;
			cal_txt.height = 300;
			
			calW = cal_txt.textWidth+4;
			calH = cal_txt.textHeight+4;
			calBlockW = calW / 14;
			
			day_mc.graphics.beginFill(0xFFFFFF, 0.7);
			day_mc.graphics.drawRect(-50, 0, 50, calH);
			day_mc.graphics.drawRect(calW*0.5, 0, 400, calH);
			day_mc.graphics.beginFill(0xFFAAAA, 0.6);
			day_mc.graphics.drawRect(0, 0, calBlockW, calH);
			day_mc.graphics.beginFill(0xAAAAFF, 0.6);
			day_mc.graphics.drawRect(calW*6/14, 0, calBlockW, calH);
			day_mc.graphics.endFill();
			day_mc.x = 50;
			day_mc.y = 100;
			
			addChild(cal_txt);
			addChild(date_txt);
			addChild(day_mc);
			
			mvCal(new TimerEvent(TimerEvent.TIMER) );
			
			calTimer.addEventListener(TimerEvent.TIMER, mvCal);
			calTimer.start();
		}
		
		
		private function mvCal(tEvt:TimerEvent):void
		{
			if(date){	upDateGoal(date);	}
			else{
				var today:Date = new Date();
				today.date=1;
				upDateGoal( today );
			}
			Tweener.addTween( cal_txt, { x:calGoalX, time:1 } );
		}

		
		private function upDateGoal(prmDate:Date):void
		{
			var day:uint = prmDate.getDay();
			if(day==0){	calGoalX = 50;	}
			else{	calGoalX = 50-calBlockW * (7-day);	}
			date_txt.text = ""+prmDate.getFullYear()+" / "+(prmDate.getMonth()+1);
			
			var year:uint = prmDate.getFullYear();
			var month:uint = prmDate.getMonth()+1;
			if(month == 12){
				month = 0;
				year ++;
			}

			date = new Date(year, month, 1);
		}
		
		
	}
	
}