ex1_digital_watch.swf |
ActionScript2.0
//フレーム読み込み時に実行 this.onEnterFrame = function() { var ampm:String; var nowTime:String; var DateObj:Date = new Date(); var hour:Number = DateObj.getHours(); var minute:Number = DateObj.getMinutes(); var second:Number = DateObj.getSeconds(); //午前午後判断 if (hour >= 0 && hour < 12) { ampm = "am"; } else if (hour >= 12 && hour <= 23) { ampm = "pm"; hour -= 12; } else { ampm = "pm"; } //流し込む文字列の結合 nowTime = ampm + DigitAdjust(hour, 2) + ":" + DigitAdjust(minute, 2) + ":" + DigitAdjust(second, 2); NowTimeView.text = nowTime; }; //桁数変換 function DigitAdjust(num, Digit:Number) { var newNum:String = num.toString(); while (newNum.length < Digit) newNum = "0" + newNum; return newNum; };ダウンロード
0 件のコメント:
コメントを投稿