求一flash数字时钟
发布网友
发布时间:2022-04-20 18:16
我来回答
共1个回答
热心网友
时间:2022-04-20 19:45
在舞台上创建一个文本框,属性设置为“动态文本”,实例名称为“tra”,“段落“一栏的”行为“改为“多行”。
点击第一帧,打开动作面板,输入以下代码:
this.onEnterFrame = function()
{
var xq:Array = new Array("日", "一", "二", "三", "四", "五", "六");
var today_date:Date = new Date();
tra.text = "";
tra.text = tra.text + today_date.getFullYear() + "年";
if (today_date.getMonth() + 1 < 10)
{
tra.text = tra.text + "0";
}
tra.text = tra.text + (today_date.getMonth() + 1) + "月";
if (today_date.getDate() < 10)
{
tra.text = tra.text + "0";
}
tra.text = tra.text + today_date.getDate() + "日\n";
tra.text = tra.text + "星期" + xq[today_date.getDay()] + "\n";
if (today_date.getHours() < 10)
{
tra.text = tra.text + "0";
}
tra.text = tra.text + today_date.getHours() + "时";
if (today_date.getMinutes() < 10)
{
tra.text = tra.text + "0";
}
tra.text = tra.text + today_date.getMinutes() + "分";
if (today_date.getSeconds() < 10)
{
tra.text = tra.text + "0";
}
tra.text = tra.text + today_date.getSeconds() + "秒";
if (today_date.getMilliseconds() < 10)
{
tra.text = tra.text + "00";
}
else if (today_date.getMilliseconds() < 100)
{
tra.text = tra.text + "0";
}
tra.text = tra.text + today_date.getMilliseconds() + "毫秒\n";
};
ctrl+enter 测试影片
大功告成!
背景和文字的颜色都可以在属性面板修改。