您现在的位置: 圆点视线 >> 教程 >> flash教程 >> 实例教学 >> 文章正文
Flash AS实例教程:用纯AS制作的钟表动画           ★★★
Flash AS实例教程:用纯AS制作的钟表动画
作者:hairan  文章来源:网页教学网  点击数:  更新时间:2007-9-2 15:21:22 
 页面功能:【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口 【字体:

[代码]把以下代码复制到主场景中的第一帧上:
//画钟表边线
this.createEmptyMovieClip("bianxian_mc", 1);
with (bianxian_mc) {
lineStyle(2, 0xCCCCCC);
moveTo(Math.cos(0*Math.PI/180)*96, Math.sin(0*Math.PI/180)*96);
for (var i = 360; i>=0; i--) {
  lineTo(Math.cos(i*Math.PI/180)*96, Math.sin(i*Math.PI/180)*96);
}
_x = 100;
_y = 100;
}
//创建时间动态文本
this.createTextField("my_txt", 2, 0, 0, 0, 0);
with (my_txt) {
autoSize = true;
textColor = 0x555555;
_x = 70;
_y = 60;
}
//画12个表格
this.createEmptyMovieClip("biaoge_mc", 3);
with (biaoge_mc) {
lineStyle(2, 0xCCCCCC);
moveTo(0, -96);
lineTo(0, -92);
_x = 100;
_y = 100;
}
for (i=1; i<12; i++) {
duplicateMovieClip(biaoge_mc, "biaoge_mc"+i, 3+i);
setProperty("biaoge_mc"+i, _rotation, i*30);
}
//画时针
this.createEmptyMovieClip("shizhen_mc", 16);
with (shizhen_mc) {
lineStyle(4, 0x666666);
moveTo(0, 0);
lineTo(0, -60);
_x = 100;
_y = 100;
}
//画分针
this.createEmptyMovieClip("fenzhen_mc", 17);
with (fenzhen_mc) {
lineStyle(2, 0x666666);
moveTo(0, 0);
lineTo(0, -75);
_x = 100;
_y = 100;
}
//画秒针
this.createEmptyMovieClip("miaozhen_mc", 18);
with (miaozhen_mc) {
lineStyle(1, 0x666666);
moveTo(0, 0);
lineTo(0, -90);
_x = 100;
_y = 100;
}
//让时针、分针、秒针动起来
this.createEmptyMovieClip("time_mc", 19);
time_mc.onEnterFrame = function() {
my_date = new Date();
shi = my_date.getHours();
fen = my_date.getMinutes();
miao = my_date.getSeconds();
shizhen_mc._rotation = shi/12*360+fen/60*30;
fenzhen_mc._rotation = fen/60*360+miao/60*6;
miaozhen_mc._rotation = miao/60*360;
if (shi<10) {
  shi = "0"+shi;

if (fen<10) {
  fen = "0"+fen;

if (miao<10) {
  miao = "0"+miao;

my_txt.text = shi+":"+fen+":"+miao;
};
//画中心圆
this.createEmptyMovieClip("yuan_mc", 20);
with (yuan_mc) {
beginFill(0x555555);
moveTo(Math.cos(0*Math.PI/180)*4, Math.sin(0*Math.PI/180)*4);
for (var i = 360; i>=0; i--) {
  lineTo(Math.cos(i*Math.PI/180)*4, Math.sin(i*Math.PI/180)*4);
}
_x = 100;
_y = 100;
 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 文章录入:hairan    责任编辑:hairan  【字体:
 
  • 上一篇文章:

  •  
  • 下一篇文章:
  • 最新文章
    相关文章
    没有相关文章
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
     姓  名: 评 分: 1分 2分 3分 4分 5分
     评论内容: ·严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
    ·用户需对自己在使用本网服务过程中的行为承担法律责任
    ·本站管理员有权保留或删除评论内容。
    ·评论内容只代表机友个人观点,与本网站立场无关。
     
    最 新 推 荐
     
    百度主题推广
    最 新 热 门