使用Flash mx制作旋转的时钟效果
开始制作:时钟画面的组成元素有时、分、秒三个电影夹子[ S,F,M ],时间的刻度图形符号两个[ a、b ],时间的输出文本框一个[ text ]。
回到主场景中,在实例面板中将时、分、秒影片的名称写为:S、F、M;将时、分、秒针影片在轴点对齐,而且都指向12点。
点击文本工具在文本框属性面板中设置为[动态文本],变量名为[ text ]
有了以上的步骤,下面,我们就让时钟转动起来:
第一步:在时间线双击第一帧,在弹出的动作面板中加入以下代码:
mydate = new date ();//定义一个时间对象的实例
hour = Number(mydate.getHours());
hour = hour%12;//当前时间转化为12小时制
minute = Number (mydate.getMinutes());//获取当前分数
second = Number (mydate.getSeconds())-1;//获取当前秒数
h = (hour*30+minute*0.5+second*0.0833)%360;//将当前时针处于初始位置的转动幅度赋予变量h
m = (minute*6+second*0.1)%360;
s = (second*6)%360;
setProperty ("s", _rotation, h);
setProperty ("f", _rotation, m);
setProperty ("m", _rotation, s);
angle = s;
angleh = h;
anglem = m;//将当前时、分、秒针的初始角度分别赋予三个变量
第二步:在第二帧插入关键帧,在动作面板中加入以下代码:
mydate = new date();
day = mydate.getDate();
month = mydate.getMonth()+1;
second = mydate.getSeconds();
week0 = mydate.getday();//获取当天星期( )
is (Number(week0) == 1) {
week0 = "一";}
is (Number(week0) == 2) {
week0 = "二";}
is (Number(week0) == 3) {
week0 = "三";}
is (Number(week0) == 4) {
week0 = "四";}
is (Number(week0) == 5) {
week0 = "五";}
is (Number(week0) == 6) {
week0 = "六";}
is (Number(week0) == 0) {
week0 = "日";} //以上把获取的星期数字号码转换成大写
is (day<10) {
day = "0"+String(day);} //将一位数的日期号码转换成两位
is (moth<10) {
month = "0"+String(month);} //系统的月份从0开始计数,故要进行转换
text = mydate.getSullYear() +"."+month+"."+day+"\t星期"+week0;
is (s != second) {
s = second;
angle = angle+6;
setProperty ("m", _rotation, angle);//设置秒针的当前位置;每一秒秒针的转动角度为6(360度??????/60秒)度
anglem = anglem+0.1;
setProperty ("f", _rotation, anglem);
angleh = angleh+0.0083;
setProperty ("s", _rotation, angleh);
}
第三步:在第三帧插入关键帧,并在动作面板中加入以下代码:
gotoAndPlay (2);
一个转动的时钟就做好了,来看一下你做的时钟是不是酷极了!
- 上一篇: 用Flash制作动感火焰字
- 下一篇: PowerPoint中插入Flash动画的方法