CSDN上显示的时钟的AS

onEnterFrame = function () {
     time_date = new Date();
     se = new String();
     var ts = time_date.getSeconds();
     se = ts;
     if (ts<10) { // 设定显示时间的格式如果是小于0,比如3,那么就显示03
          se = "0"+ts;
     }
     mi = new String();
     var tm = time_date.getMinutes();
     mi = tm;
     if (tm<10) {
         mi = "0"+tm;
     }
     ho = new String();
     var th = time_date.getHours();
     ho = th;
     if (th<10) {
          ho = "0"+th;
     }
     time_txt.text = ho+":"+mi+":"+se;  // 显示格式为 xx : xx : xx
     date_txt.text = (time_date.getYear()-100)+"' "+time_date.getDate()+" "+(time_date.getMonth()+1);
     var week = new String();
     switch (time_date.getDay()) {  // 设定星期的格式
         case 1 :
              week = "Mon";
              break;
         case 2 :
              week = "Tus";
              break;
         case 3 :
              week = "Wed";
              break;
         case 4 :
              week = "Thu";
              break;
         case 5 :
              week = "Fri";
              break;
         case 6 :
              week = "Sta";
              break;
         case 0 :
              week = "Sun";
              break;
     }
     if (!time_date.getDay()) {  // 特殊设定,当天如果是星期天,那么把字体显示为红色
          week_txt.textColor = 0xdd0000;  // textColor后是跟一个16进制的颜色,这里为红色
     }
     week_txt.text = week;
};

// AS中的以_txt结尾的就是动态文本的"标签"(实例名称),可以调用text以及textColor属性
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值