源文件下载
>点击查看动画效果<实例2-6时钟
基本思路
① 作 3 个指针 MC ,分别按不同的速度旋转,实现时钟效果。
②若 要拖拽效果,则要把 12 个数字分别作成 MC 。然后作鼠标跟随。
新知识点 ① Date 类的方法的应用:
复制代码
MY Date= new Date()// 构造一个新的 Date 对象
Date.getHours()// 按照本地时间返回小时值。
Date.getMinutes()// 按照本地时间返回分钟值。
Date.getSeconds()// 按照本地时间返回秒数。
Date.getMilliseconds()// 按照本地时间返回毫秒值。
②一种缓冲公式应用
实例说明
①此时钟实例是由数字和指针共 15 个 MC 组成,并又是嵌套在 MC “ biao” 中,各 MC 的注册点一定要确定准确,
② 分别将 MC “ biao” 放在主时间轴的 3 个帧上,为各帧上的 MC 编写不同的脚本。
③ 设一按钮用于各帧之间的跳转
编写动作脚本 ① 在第 1 帧到第 2 帧的 MC 上输入:
复制代码
onClipEvent (enterFrame) {// 以影片剪辑帧频不断触发的动作
s = new Date();// 创健日期对象
Hours = s.getHours();// 读取系统时间 - 时
if (12<Hours) {
Hours = Hours-12;
}// 把 24 小时制转换为 12 小时制
this.b13._rotation = ((Hours*30)+(s.getMinutes()/2)); // 把时和分转换为旋转角度
this.b14._rotation = (6*s.getMinutes()); // 把获取的系统时间分转换为旋转角度
this.b15._rotation = (6*s.getSeconds()); // 把获取的系统时间秒转换为旋转角度
}
② 在第 3 帧的 MC 上输入:
复制代码
onClipEvent (load) {变量初始化
for (i=1; i<16; i++) {
this["b"+i].xl = 0;
this["b"+i].yl = 0;
}
}
onClipEvent (enterFrame) {
s = new Date();
Hours = s.getHours();
if (12<Hours) {
Hours = Hours-12;
}
this.b13._rotation = ((Hours*30)+(s.getMinutes()/2));
this.b14._rotation = (6*s.getMinutes());
this.b15._rotation = (6*s.getSeconds());
this.b1._x = _xmouse;
this.b1._y = _ymouse+120; // 让第一个 MC 跟随鼠标移动 ,并要MC低于鼠标120个像素。
for (i=2; i<=15; i++) {
this["b"+i].xl = (this["b"+(i-1)]._x-this["b"+i]._x)/2+this["b"+i].xl*0.3;// 变量 bi.xl 在趋于 0 的过程中不断被赋新值
this["b"+i].yl = (this["b"+(i-1)]._y-this["b"+i]._y)/2+this["b"+i].yl*0.3;// 变量 bi.yl 在趋于 0 的过程中不断被赋新值










