More Related Content
More from focusstorm124 (17)
วิธีการทำ Digital clock
- 1. บทความนี้เราจะ สร้างนาฬิกาในรูปแบบ Digital กันนะครับ มาลองดูวิธี
ทากันเลยครับ
1. สร้างเอกสารใหม่ขึ้นมาขนาด 180x40 ดังรูป
2. ใช้เครื่องมือ text tool สร้าง textbox ขึ้นมา แล้วให้ตั้งชื่อว่า
clock_txt ดังรูป
3. ตั้งชื่อ layer ว่า text
4. สร้าง layer ใหม่ขึ้นมา ตั้งชื่อว่า action
- 2. 5. คลิกที่เฟรมแรก กด F9 หรือคลิกขวาแล้วเลือก action
6. ใส่ action script ลงไปดังนี้
time=new Date(); // time object
var seconds = time.getSeconds()
var minutes = time.getMinutes()
var hours = time.getHours()
if (hours<12) {
ampm = "AM";
- 3. }
else{
ampm = "PM";
}
while(hours >12){
hours = hours - 12;
}
if(hours<10)
{
hours = "0" + hours;
}
if(minutes<10)
{
minutes = "0" + minutes;
}
if(seconds<10)
{
seconds = "0" + seconds;
}
clock_txt.text = hours + ":" + minutes + ":" + seconds +" "+
ampm;
7. เพิ่มเฟรมขึ้นมาอีกหนึ่งเฟรม ดังรูป