ex7_analg_digital_watch_lite2.swf |
ActionScript2.0
action layer
this.onEnterFrame = function() { var DateObj:Date = new Date(); var hour:Number = DateObj.getHours(); var min:Number = DateObj.getMinutes(); var sec:Number = DateObj.getSeconds(); var youbi:Number = DateObj.getDay(); var mon:Number = DateObj.getMonth(); var date:Number = DateObj.getDate(); var year:Number = DateObj.getFullYear(); this.week.gotoAndStop(youbi+1); sHand._rotation = sec * 6; mHand._rotation = (min * 60 + sec) * 0.1; hHand._rotation = (hour * 60 + min) * 0.5; numDisp((hour*10000)+(min*100)+sec,6,"numMc"); numDisp(((mon+1)*100)+date,4,"date"); numDisp(year,4,"y"); } function DigitAdjust(num,Digit:Number) { var newNum:String = num.toString(); while(newNum.length < Digit) { newNum = "0" + newNum; } return newNum; } function numDisp(getNum:Number,keta:Number,str:String):Void { var i:Number = 0; var maxNum:Number = Math.pow(10,keta) - 1; var num:Number = Math.max(Math.min(getNum,maxNum),0); var strNum:String = "0000" + String(num); strNum = strNum.substr(strNum.length - keta,keta); for(i = 0;i < keta;i++) { this[str + i].gotoAndStop(Number(strNum.charAt(i)) + 1); } } stop();digital layer
//デジタル時計 this.onEnterFrame = function() { var Dateobj:Date = new Date(); var hour:Number = Dateobj.getHours(); var minute:Number = Dateobj.getMinutes(); var second:Number = Dateobj.getSeconds(); var month:Number = Dateobj.getMonth()+1; var day:Number = Dateobj.getDate(); var youbi:Number = Dateobj.getDay(); var year:Number = Dateobj.getYear(); this.numDisp(hour, 0, 2); this.numDisp(minute, 1, 2); this.numDisp(second, 2, 2); this.numDisp(month, 3, 2); this.numDisp(day, 4, 2); this.numDisp(youbi, 5, 1); this.numDisp(year, 6, 4); SetTime(); tlD = setInterval(SetTime, 250); }; function numDisp(getNum:Number, output:Number, keta:Number):Void { var i:Number = 0; var maxNum:Number = Math.pow(10, keta)-1; var num:Number = Math.max(Math.min(getNum, maxNum), 0); var strNum:String = "0000"+String(num); strNum = strNum.substr(strNum.length-keta, keta); for (i=0; i<keta; i++) { switch (output) { case 0 : this["numMcHour"+i].gotoAndStop(Number(strNum.charAt(i))+1); break; case 1 : this["numMcMin"+i].gotoAndStop(Number(strNum.charAt(i))+1); break; case 2 : this["numMcSec"+i].gotoAndStop(Number(strNum.charAt(i))+1); break; case 3 : this["MCmonth"+i].gotoAndStop(Number(strNum.charAt(i))+1); break; case 4 : this["MCday"+i].gotoAndStop(Number(strNum.charAt(i))+1); break; case 5 : this["MCyoubi"].gotoAndStop(Number(strNum.charAt(i))+1); break; case 6 : this["MCyear"+i].gotoAndStop(Number(strNum.charAt(i))+1); break; } } } function SetTime() { nowDate = new Date(); hour = nowDate.getHours(); min = nowDate.getMinutes(); sec = nowDate.getSeconds(); sHand._rotation = sec*6; mHand._rotation = (min*60+sec)*0.1; hHand._rotation = (hour*60+min)*0.5; }ダウンロード
0 件のコメント:
コメントを投稿