1. 重庆云诚科技 > 互联网资讯 >

┏ 编程罗盘时钟制作教程 ┛制作动态罗盘时钟的代码

导读求一个javascript脚本写的动态时钟本文贡献者:【未簖奶】, 疑问关键字:编程罗盘时钟制作教程, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!贡献者回答// 显...

今天重庆云诚科技就给我们广大朋友来聊聊编程罗盘时钟制作教程,以下3个关于制作动态罗盘时钟的代码的观点希望能帮助到您找到想要的答案。

求一个javascript脚本写的动态时钟

本文贡献者:【未簖奶】, 疑问关键字:编程罗盘时钟制作教程, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

贡献者回答// 显示系统时间

function show(){

var date = new Date(); //日期对象

var now = "";

var myweekday=date.getDay();

var weekday="";

now = date.getFullYear()+"年"; //读英文就行了

now = now + (date.getMonth()+1)+"月"; //取月的时候取的是当前月-1如果想取当前月+1就可以了

now = now + date.getDate()+"日 ";

if(myweekday== 0)

weekday=" 星期日 ";

else if(myweekday == 1)

weekday=" 星期一 ";

else if(myweekday == 2)

weekday=" 星期二 ";

else if(myweekday == 3)

weekday=" 星期三 ";

else if(myweekday == 4)

weekday=" 星期四 ";

else if(myweekday == 5)

weekday=" 星期五 ";

else if(myweekday == 6)

weekday=" 星期六 "; now = now +weekday;

now = now + date.getHours()+" :";

if(date.getMinutes().toString().length==2)

now = now + date.getMinutes()+" :";

else

now = now + "0"+date.getMinutes()+" :";

if(date.getSeconds().toString().length==2)

now = now + date.getSeconds();

else

now = now + "0"+date.getSeconds();

document.getElementById("nowDiv").innerHTML = now; //div的html是now这个字符串

setTimeout("show()",1000); //设置过1000毫秒就是1秒,调用show方法

}

//下面是使用方法 1:在body里页面加载时 激活该方法<body onload="show();">2: <div id="nowDiv" style="float: left;">在需要显示时间的地方 定义一个div 层 id=“nowDiv” 然后就看效果就可以了

上文就是重庆云诚科技小编分享贡献者:(未簖奶)分析的关于“求一个javascript脚本写的动态时钟”的问题了,不知是否已经解决你的问题?如果没有,下一篇内容可能是你想要的答案,现在接着继续讨论下文用户【如梦.】解答的“vb制作表盘时钟 并含有数字 要代码”的一些相关问题做出分析与解答,如果能找到你的答案,可以关注本站。

求一个javascript脚本写的动态时钟

vb制作表盘时钟 并含有数字 要代码

本文贡献者:【如梦.】, 疑问关键字:编程罗盘时钟制作教程, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

贡献者回答把以下代码保存成一个后缀名为.FRM的文件中,再用VB打开即可。

=====================

VERSION 5.00

Begin VB.Form frmClock

BorderStyle = 1 'Fixed Single

Caption = "钟 by YTY"

ClientHeight = 2550

ClientLeft = 45

ClientTop = 330

ClientWidth = 2505

DrawWidth = 2

Icon = "Form1.frx":0000

LinkTopic = "Form1"

MaxButton = 0 'False

MinButton = 0 'False

ScaleHeight = 2550

ScaleLeft = -1000

ScaleMode = 0 'User

ScaleTop = -1000

ScaleWidth = 2505

StartUpPosition = 3 '窗口缺省

Begin VB.Timer Timer1

Interval = 1000

Left = 120

Top = 2280

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 11

Left = 0

TabIndex = 12

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 10

Left = 0

TabIndex = 11

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 9

Left = 0

TabIndex = 10

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 8

Left = 0

TabIndex = 9

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 7

Left = 0

TabIndex = 8

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 6

Left = 0

TabIndex = 7

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 5

Left = 0

TabIndex = 6

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 4

Left = 0

TabIndex = 5

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 3

Left = 0

TabIndex = 4

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 2

Left = 0

TabIndex = 3

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 1

Left = 0

TabIndex = 2

Top = 0

Width = 375

End

Begin VB.Label Label2

Caption = "Label2"

Height = 375

Index = 0

Left = 960

TabIndex = 1

Top = 120

Width = 375

End

Begin VB.Label Label1

Caption = "Label1"

BeginProperty Font

Name = "Arial"

Size = 12

Charset = 0

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 615

Left = 0

TabIndex = 0

Top = 1800

Width = 2655

End

End

Attribute VB_Name = "frmClock"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Dim h As Integer, m As Integer, s As Integer, t

Const pi As Double = 3.14159265358979

Private Sub Form_Load()

Timer1.Interval = 1000

Me.ScaleLeft = -1000

Me.ScaleTop = -1000

For i = 0 To 11

Label2(i).AutoSize = True

Label2(i).Caption = i + 1

Label2(i).Left = 700 * Cos((i * 30 - 60) * pi / 180) - 80

Label2(i).Top = 700 * Sin((i * 30 - 60) * pi / 180) - 100

Next

End Sub

Private Sub Label1_Click()

t = InputBox("请输入时间")

If IsDate(t) = True Then

Label1.Caption = t

Timer1.Enabled = False

Refresh

For i = 1 To 60

PSet (600 * Cos(i * 6 * pi / 180), 600 * Sin(i * 6 * pi / 180)), vbBlack

Next

h = Format(t, "h")

m = Format(t, "n")

s = Format(t, "s")

Line (0, 0)-(300 * Cos(h * pi / 6 - pi / 2), 300 * Sin(h * pi / 6 - pi / 2)), vbRed

Line (0, 0)-(500 * Cos(m * pi / 30 - pi / 2), 500 * Sin(m * pi / 30 - pi / 2)), vbBlue

Line (0, 0)-(600 * Cos(s * pi / 30 - pi / 2), 600 * Sin(s * pi / 30 - pi / 2)), vbGreen

End If

End Sub

Private Sub Timer1_Timer()

Refresh

For i = 1 To 60

PSet (600 * Cos(i * 6 * pi / 180), 600 * Sin(i * 6 * pi / 180)), vbBlack

Next

Label1.Caption = Now

h = Format(Now, "h")

m = Format(Now, "n")

s = Format(Now, "s")

Line (0, 0)-(300 * Cos(h * pi / 6 - pi / 2), 300 * Sin(h * pi / 6 - pi / 2)), vbRed

Line (0, 0)-(500 * Cos(m * pi / 30 - pi / 2), 500 * Sin(m * pi / 30 - pi / 2)), vbBlue

Line (0, 0)-(600 * Cos(s * pi / 30 - pi / 2), 600 * Sin(s * pi / 30 - pi / 2)), vbGreen

End Sub

上文就是重庆云诚科技小编分享贡献者:(如梦.)分析的关于“vb制作表盘时钟 并含有数字 要代码”的问题了,不知是否已经解决你的问题?如果没有,下一篇内容可能是你想要的答案,下面继续浅析下文用户【桃花散漫】分享的“怎样用FLASH做一个会动的时钟?”的一些相关疑问做出分析与解答,如果能找到你的答案,可以关注本站。

怎样用FLASH做一个会动的时钟?

本文贡献者:【桃花散漫】, 疑问关键字:编程罗盘时钟制作教程, 下面就让重庆云诚科技小编为你解答,希望本文能找到您要的答案!

贡献者回答具体步骤

1、 运行Flash MX 2004,新建影片剪辑,命名为“表盘”。进入编辑区绘制一条直线,单击【窗口】|【设计面板】|【变形】命令,打开变形面板,添入旋转角度为30度,拷贝并应用变形。按照同样方法,绘制出其他分钟的刻度。

2、 在背景层中我们添加三个动态文本框,变量名称为:“weeks”,“days”和“timebox”。

3、 分别新建三个影片剪辑,命名为“时针”,“分针”,“秒针”。绘制三个指针的形状。注意指针的中心点的位置。

4、 导入一段指针移动的模拟音乐。在声音文件的连接属性中选择“为动作脚本导出”,命名为“sound”。

5、 新建一个影片剪辑,命名为“音乐”。在第1帧添加as:stop(); 第2帧插入空白关键帧,添加as:

ss = new Sound();

ss.attachSound("sound");

ss.start();

ss.onSoundComplete = function() {

ss.start();

}; //调用库中的声音文件sound

6、返回到场景1,把“表盘”影片剪辑拖放到舞台中,利用对齐面板使之处与舞台中央位置。

7、新建一个图层,绘制一个中心点。同样利用对齐面板使之处与中央位置。

8、新建三个图层,分别放置“时针”,“分针”,“秒针”影片剪辑。注意,影片剪辑的中心点要与步骤6绘制的中心点重合。

1、 新建一个音乐层,把“音乐”影片剪辑放置在场景的任何位置。在下面的属性面板中,命名为“777”。

2、 分别选择“时针”,“分针”,“秒针”三个影片剪辑,在下面的属性面板中分别命名为“hourpoints”,“minutepoints”和“secondpoints”。

3、 好了,准备工作已经完成了。下面我们添加AS。

4、 选中“表盘”影片剪辑,添加as语句:

onClipEvent (load) {

weekArray = new Array(’星期日’, ’星期一’, ’星期二’, ’星期三’, ’星期四’, ’星期五’, ’星期六’);//建立一个数组,共七个元素

timedate = new Date();//建立一个新的时间对象

}

onClipEvent (enterFrame) {

week = timedate.getDay();//返加0~6,0时取“星期日”;1时取“星期一”…….

weekday = weekArray[week];//从数组中读取中文显示,参看上一句的解释

day = timedate.getDate();//当前的日期,返回值为1~31

hour = timedate.getHours();//当前的时,返回0~23

minute = timedate.getMinutes();当前的分,返回0~59

second = timedate.getSeconds();当前的秒,返回0~59

if (hour<10) {

hour = "0" + hour;//如果时小于10,前面显示加“0”

}

if (minute<10) {

minute = "0" + minute;//同上

}

if (second<10) {

second = "0" + second;//同上

}

timebox = hour+" : "+minute+" : "+second;//显示在动态文本框中

weeks = weekday;//同上一句

days = day;//同上一句

delete timedate;//删除时间对象,目的是实时显示时间

timedate = new Date();//新建时间对象

}

5、 选择“时针”影片剪辑,添加as语句:

onClipEvent (enterFrame) {

hourangle = _root.clock.hour*30+_root.clock.minute/2;

//把钟表符号中的时针对应的角度值赋值给变量“hourangle”

setProperty ("_root.hourpoints", _rotation, hourangle);

}//设置分针的旋转角度

6、 选择“分针”影片剪辑,添加as语句:

onClipEvent (enterFrame) {

minuteangle = _root.clock.minute*6;

//把钟表符号中的分针对应的角度值赋值给变量“minuteangle”

setProperty ("_root.minutepoints", _rotation, minuteangle);

}//设置分针的旋转角度

7、 选择“秒针”影片剪辑,添加as语句:

onClipEvent (enterFrame) {

secondsangle = _root.clock.second*6;

//把钟表符号中的秒针对应的角度值赋值给变量“secondsangle”

setProperty ("_root.secondpoints", _rotation, secondsangle);

}//设置秒针的旋转角度

16、测试,保存。请参看源文件“时钟”。

特别说明

要实现指针式双历钟表,要掌握的知识包括:FLASH的日期型函数和变量的使用,文本框的设置,时间显示的调整,数组的简单应用,以及如何实时的、动态的显示时间;最主要的是利用指针的角度与当前时间的函数关系,才能使时钟准确的指示时间。从中可以看出,如果推理不出这个函数关系,就做不成。所以我们应该多学习一下,多练练自己的逻辑思维能力

关于[编程罗盘时钟制作教程]的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于编程罗盘时钟制作教程、制作动态罗盘时钟的代码的信息别忘了在本站进行查找喔。

推荐文章:

  • 膜的组词和部首,膜的组词和拼音是什么
  • 亲字组词100个 亲字的组词有
  • 酬谢是什么意思,定当酬谢是什么意思
  • 异的组词和部首,株的组词和部首
  • 箭组词和拼音 耸组词和拼音部首
  • 有志不在年高的意思-有志不在年高的意思雨来表达了
  • 繁衍的意思 繁衍的意思简单解释
  • 彤组词,胀组词和拼音
  • 血泊的拼音 泊的拼音
  • 螺组词拼音 螺的组词和拼音
  • 本文由网上采集发布,不代表我们立场,转载联系作者并注明出处:https://www.cqycseo.com/zixun/4754.html

    联系我们