在flash mx中如何实时显示系统时间的实例 10
2个回答
展开全部
实时显示当明系统时间:
var today:Date;
var todayYear:Number;
var todayMonth:Number;
var todayDay:Number;
var todayWeek:String;
var nowHour:Number;
var nowMinute:Number;
var nowSecond:Number;
var weekArray:Array;
var dayShow:String;
var monthShow:String;
var hourShow:String;
var minuteShow:String;
var secondShow:String;
var timer:Timer;
timer=new Timer(100);
timer.addEventListener(TimerEvent.TIMER,deal);
timer.start();
function timeInit() //
{
weekArray=new Array("日","一","二","三","四","五","六");
today=new Date();
todayYear=today.getFullYear();
todayMonth=today.getMonth();
todayDay=today.getDate();
todayWeek=weekArray[new int(today.getDay())];
nowHour=today.getHours();
nowMinute=today.getMinutes();
nowSecond=today.getSeconds();
}
function deal(evt:Event)
{
timeInit();
dealWith(todayMonth,todayDay,nowHour,nowMinute,nowSecond);
//timeShow这是一个舞台里面的对态文本对象,实例名叫timeShow用来显示日期与时间的
timeShow.text="现在是"+todayYear+"年"+monthShow+"月"+dayShow+"日 "+hourShow+":"+minuteShow+":"+secondShow+" 星期"+todayWeek;
}
function dealWith(paraMonth,paraDay,paraHour,paraMinute,paraSecond)
{
if (paraMonth<10)
{
monthShow="0"+(todayMonth+1);
} else
{
monthShow=(todayMonth+1).toString();
}
if (paraDay<10)
{
dayShow="0"+todayDay;
} else
{
dayShow=todayDay.toString();
}
if (paraHour<10)
{
hourShow="0"+nowHour;
} else
{
hourShow=nowHour.toString();
}
if (paraMinute<10)
{
minuteShow="0"+nowMinute;
} else
{
minuteShow=nowMinute.toString();
}
if (paraSecond<10)
{
secondShow="0"+nowSecond;
} else
{
secondShow=nowSecond.toString();
}
}
var today:Date;
var todayYear:Number;
var todayMonth:Number;
var todayDay:Number;
var todayWeek:String;
var nowHour:Number;
var nowMinute:Number;
var nowSecond:Number;
var weekArray:Array;
var dayShow:String;
var monthShow:String;
var hourShow:String;
var minuteShow:String;
var secondShow:String;
var timer:Timer;
timer=new Timer(100);
timer.addEventListener(TimerEvent.TIMER,deal);
timer.start();
function timeInit() //
{
weekArray=new Array("日","一","二","三","四","五","六");
today=new Date();
todayYear=today.getFullYear();
todayMonth=today.getMonth();
todayDay=today.getDate();
todayWeek=weekArray[new int(today.getDay())];
nowHour=today.getHours();
nowMinute=today.getMinutes();
nowSecond=today.getSeconds();
}
function deal(evt:Event)
{
timeInit();
dealWith(todayMonth,todayDay,nowHour,nowMinute,nowSecond);
//timeShow这是一个舞台里面的对态文本对象,实例名叫timeShow用来显示日期与时间的
timeShow.text="现在是"+todayYear+"年"+monthShow+"月"+dayShow+"日 "+hourShow+":"+minuteShow+":"+secondShow+" 星期"+todayWeek;
}
function dealWith(paraMonth,paraDay,paraHour,paraMinute,paraSecond)
{
if (paraMonth<10)
{
monthShow="0"+(todayMonth+1);
} else
{
monthShow=(todayMonth+1).toString();
}
if (paraDay<10)
{
dayShow="0"+todayDay;
} else
{
dayShow=todayDay.toString();
}
if (paraHour<10)
{
hourShow="0"+nowHour;
} else
{
hourShow=nowHour.toString();
}
if (paraMinute<10)
{
minuteShow="0"+nowMinute;
} else
{
minuteShow=nowMinute.toString();
}
if (paraSecond<10)
{
secondShow="0"+nowSecond;
} else
{
secondShow=nowSecond.toString();
}
}
展开全部
做一个mc,里面放一个名为_txt的动态文本框,帧上写代码:
CW = ["日", "一", "二", "三", "四", "五", "六"];//星期的大写数字
this.onEnterFrame = function () {
TD = new Date();
w = TD.getDay();//0--6
_txt.text = "提醒您现在是:\n"+TD.getFullYear()+"年"+(TD.getMonth()+1)+"月"+TD.getDate()+"日"+TD.getHours()+"时"+TD.getMinutes()+"分"+TD.getSeconds()+"秒"+" "+"星期"+CW[w];
};
//使用时将mc放到舞台任意位置。
如果看不懂,hi我发你文件。
CW = ["日", "一", "二", "三", "四", "五", "六"];//星期的大写数字
this.onEnterFrame = function () {
TD = new Date();
w = TD.getDay();//0--6
_txt.text = "提醒您现在是:\n"+TD.getFullYear()+"年"+(TD.getMonth()+1)+"月"+TD.getDate()+"日"+TD.getHours()+"时"+TD.getMinutes()+"分"+TD.getSeconds()+"秒"+" "+"星期"+CW[w];
};
//使用时将mc放到舞台任意位置。
如果看不懂,hi我发你文件。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询