ActionScript2.0

Dateクラス

デジタル時計

ムービークリップインスタンス名:time_mc)の中にダイナミックテキスト(h_txt,m_txt,s_txt)を入れて、タイムライン上に以下のActionScriptを記述

time_mc.onEnterFrame=function(){
var new_time:Date=new Date();
time_mc.h_txt.text=new_time.getHours();

minute=new_time.getMinutes();
if(minute < 10) {minute="0"+minute;};
time_mc.m_txt.text=minute;

second=new_time.getSeconds();
if(second < 10) {second = "0" + second;};
time_mc.s_txt.text=second;
};
アナログ時計


長針(minutes_mc)、短針(hours_mc)、秒針(seconds_mc)としてタイムラインフレーム上にActionScriptを記述

this.onEnterFrame=function(){
	var time:Date=new Date();
	seconds_mc._rotation=time.getSeconds()/60*360;
	minutes_mc._rotation=time.getMinutes()/60*360;
	hours_mc._rotation=time.getHours()/24*720+time.getMinutes()/60*30;
}
カレンダー


年(インスタンス名:y)、月(m)、日(d)、曜日(w)をタイムラインにて記述

var new_date:Date=new Date();
this.onEnterFrame=function(){
	y.text=new_date.getFullYear()+"年";
	m.text=new_date.getMonth()+1+"月";
	d.text=new_date.getDate()+"日";
	week=new Array("日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日");
	w.text=week[new_date.getDay()];		   
}