惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
L
LINUX DO - 最新话题
The Register - Security
The Register - Security
T
Threatpost
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Attack and Defense Labs
Attack and Defense Labs
T
Tailwind CSS Blog
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog
H
Heimdal Security Blog
小众软件
小众软件
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Exploit Database - CXSecurity.com
AWS News Blog
AWS News Blog
腾讯CDC
博客园 - 司徒正美
美团技术团队
L
LINUX DO - 热门话题
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
N
News and Events Feed by Topic
J
Java Code Geeks
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
U
Unit 42
V2EX - 技术
V2EX - 技术
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tor Project blog
H
Help Net Security
The GitHub Blog
The GitHub Blog
L
Lohrmann on Cybersecurity
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
PCI Perspectives
PCI Perspectives
W
WeLiveSecurity
A
About on SuperTechFans
N
News and Events Feed by Topic
博客园 - 叶小钗
Cloudbric
Cloudbric
L
LangChain Blog
WordPress大学
WordPress大学
B
Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

博客园 - songsoft

Js表单验证控件-02 Ajax验证 Js表单验证控件(使用方便,无需编码)-01使用说明 字符串对比 KindEditor编辑器For DotNet控件 模板引擎开发(三)-自定义标签的处理 模板引擎开发(二)-值标签的处理 Jquery插件-浮动广告 模板引擎开发(一) 软件开发模型之一 万祖归宗是瀑布 关于制度化管理 关于加薪的策略 关于文档编写 蓝海与红海--有感于软件创新 李广难封--有感于团队建设 哪里是乐土?--关于团队良性循环 从酒桌上看团队建设 创造一切条件让大家“混” 百万富翁成长路线 绿有四季--关于需求沟通
Flash AS实现时钟效果(全脚本实现)
songsoft · 2013-06-21 · via 博客园 - songsoft

这个时钟效果是全部采用脚本实现,图形也是用脚本绘制的。写于2005年,当然还是基于As2.0编写。现在想想自己当时也是闲得没事儿,竟然写这个东东。呵呵。2005年啊,8年前……无限回味啊,当初自己还是个小菜鸟,写出这样的东西真不容易,现在都想不起怎么写出来的了。里面用到了圆方程!当时刚出校门,理论基础还算扎实,现在什么都忘记了。

/*
一个表的效果,全AS绘制,只需把一下面的代码全复制到
第一帧就OK了。
作者:晴风 10522779
*/ //生成元件的起始深度值 var lv:Number = 100; //钟表的半径 var radius:Number = 100; // 钟表跟随鼠标的速度 var speed:Number = 5; //钟表的颜色值及透明度 var my_color = 0xB1C0F3; var my_line = 0xffffff; var my_alpha = 100; //用于圆形方程计算 var p:Number = 0; var n:Number = 0; //设定文本样式的函数 function text_CSS(word) { CSS = new TextFormat(); CSS.size = radius*.14; //文本居中 CSS.align = "center"; //文本的颜色 CSS.color = my_color; //CSS.color = Math.floor(Math.random()*255) << 16 | Math.floor(Math.random()*255) << 8 | Math.floor(Math.random()*255); word.setTextFormat(CSS); } //生成一续列,动态文本字段 for (i=0; i<=30; i++) { createTextField("time"+i, lv++, 0, 0, radius*0.2, radius*.2); this["time"+i].selectable = false; this["time"+i]._alpha = my_alpha/3; } //生成标志文本 createTextField("biaozi", lv++, 0, 0, radius*0.6, radius*0.2); biaozi.text = "晴风时钟"; biaozi._alpha = my_alpha/3; text_CSS(biaozi); //绘制中心点 createEmptyMovieClip("zhongxin", lv++); with (zhongxin) { beginFill(0xffffff, my_alpha); moveTo(-2, 2); lineTo(2, 2); lineTo(2, -2); lineTo(-2, -2); lineTo(-2, 2); endFill(); _x = 200; _y = 150; _width = _height=radius*.04; } //绘制时针 createEmptyMovieClip("shi", lv++); with (shi) { beginFill(my_color, my_alpha); lineStyle(1, my_line, my_alpha/2); moveTo(-5, 6); lineTo(0, 10); lineTo(5, 6); lineTo(3, -35); lineTo(0, -37); lineTo(-3, -35); lineTo(-5, 6); endFill(); _x = _parent.zhongxin._x; _y = _parent.zhongxin._y; _height = radius*.50; _width = _height*.25; } //绘制分针 createEmptyMovieClip("fen", lv++); with (fen) { beginFill(my_color, my_alpha/3*2); lineStyle(1, my_line, my_alpha); moveTo(-3, 10); lineTo(0, 13); lineTo(3, 10); lineTo(2, -60); lineTo(-2, -60); lineTo(-3, 10); endFill(); _x = _parent.zhongxin._x; _y = _parent.zhongxin._y; _height = radius*.65; _width = _height*.15; } //绘制秒针 createEmptyMovieClip("miao", lv++); with (miao) { beginFill(my_color, my_alpha/2); moveTo(-1.5, 15); lineTo(1.5, 15); lineTo(.5, -65); lineTo(-.5, -65); lineTo(-1.5, 15); endFill(); //绘制秒针上的红星 beginFill(my_color, my_alpha); moveTo(-2, -53); lineTo(2, -53); lineTo(2, -55); lineTo(-2, -55); lineTo(-2, -53); endFill(); _x = _parent.zhongxin._x; _y = _parent.zhongxin._y; _height = radius*.7; _width = _height*.05; } //绘制刻度 for (m=1; m<=12; m++) { createEmptyMovieClip("kedu"+m, lv++); with (this["kedu"+m]) { //刻度为几边形的图案 var num:Number = 6; //刻度的半径 var r:Number = radius*0.12; var p:Number = 2*Math.PI/num; var start_x:Array = new Array(); var start_y:Array = new Array(); for (i=0; i<num; i++) { start_x[i] = Math.sin(p*i)*r; start_y[i] = Math.cos(p*i)*r; lineStyle(.5, my_color, my_alpha/1.5); for (n=0; n<num; n++) { moveTo(start_x[i], start_y[i]); lineTo(start_x[n], start_y[n]); } } } } //中心点调到最前面 zhongxin.swapDepths(lv+1000); onEnterFrame = function () { now_date = new Date(); zhongxin._rotation = now_date.getSeconds()*12; miao._rotation = now_date.getSeconds()*6; fen._rotation = now_date.getMinutes()*6; // +now_date.getSeconds()*.1; shi._rotation = now_date.getHours()*30+now_date.getMinutes()*.5; // 当前时间数组,依次为:年,月,日,周,时,分,秒。 var now = new Array(now_date.getFullYear(), now_date.getMonth()+1, now_date.getDate(), now_date.getDay(), now_date.getHours(), now_date.getMinutes(), now_date.getSeconds()); var xingqi = new Array("日", "一", "二", "三", "四", "五", "六"); var riqi = now[0]+"年"+now[1]+"月"+now[2]+"日"+" "+"星期"+xingqi[now[3]]; var shijian = now[4]+"点"+now[5]+"分"+now[6]+"秒 "; var now_time:String; switch (Math.floor(now[4]/4)) { case 0 : now_time = riqi+" "+"凌晨"+" "+shijian; break; case 1 : now_time = riqi+" "+"早上"+" "+shijian; break; case 2 : now_time = riqi+" "+"上午"+" "+shijian; break; case 3 : now_time = riqi+" "+"中午"+" "+shijian; break; case 4 : now_time = riqi+" "+"下午"+" "+shijian; break; case 5 : now_time = riqi+" "+"晚上"+" "+shijian; break; } p = 2*Math.PI/now_time.length; for (i=0; i<=now_time.length; i++) { // 逐个给动态文本赋值 this["time"+i].text = now_time.charAt(i); // 引用函数text_CSS,设定动态文本样式 text_CSS(this["time"+i]); var mc = this["time"+i]; mc._y += ((Math.cos(n+p*i)*radius+zhongxin._y-radius*0.1)-mc._y)/speed; mc._x += ((Math.sin(n+p*i)*radius+zhongxin._x-radius*0.1)-mc._x)/speed; // mc._yscale = mc._xscale=(mc._y-bb._y)/2+100; mc.swapDepths(lv+mc._y-zhongxin._y); } // 转动速度 n -= .02; // 时针.分针.秒针,全部跟随中心点,中心点随鼠标 shi._x = fen._x=miao._x=zhongxin._x += (_xmouse+radius*1.2-zhongxin._x)/speed; shi._y = fen._y=miao._y=zhongxin._y += (_ymouse+radius*1.2-zhongxin._y)/speed; // 标志也跟随中心点 biaozi._x += (zhongxin._x-biaozi._x)/speed-biaozi._width/10; biaozi._y += (zhongxin._y+radius*0.3-biaozi._y)/speed; // 布置刻度 p = 2*Math.PI/12; for (i=1; i<=12; i++) { this["kedu"+i]._y += ((Math.cos(p*i)*radius*.75+zhongxin._y)-this["kedu"+i]._y)/speed; this["kedu"+i]._x += ((Math.sin(p*i)*radius*.75+zhongxin._x)-this["kedu"+i]._x)/speed; } updateAfterEvent(); };