发布网友 发布时间:2022-05-15 18:13
共2个回答
热心网友 时间:2024-02-26 05:19
代码
var jd = 0, i = 0, mr1, mr2, m, m1, m2, logo, mousex, mousey, cx, cy, shi = 0, prevr = 0, fen = 0;
logo = false;
mr = shizhen._rotation;
//时针旋转角度
shizhen.onPress = function() {
logo = true;
};
shizhen.onRelease = function() {
logo = false;
};
shizhen.onReleaseOutside = function() {
logo = false;
};
shizhen.onMouseMove = function() {
if (logo) {
mousex = _xmouse;
mousey = _ymouse;
cx = mousex-shizhen._x;
cy = mousey-shizhen._y;
mr1 = Math.atan2(cx, cy)*180/Math.PI;
//计算鼠标现在位置与参考元件Y轴的夹角
mr2 = 180-mr1;
//将夹角转换成时针的角度
shizhen._rotation = mr2;
//设置时针角度
jd = int(mr2*10)/10;
//显示时针角度(保留一位小数)
shi = int(mr2/30);
//时
fen = int((mr2*2-int(mr2/30)*60)*10)/10;
//分
fenzhen._rotation = mr2*12;
//分针旋转角度。
}
};
m = fenzhen._rotation;
//分针角度
fenizhen.onPress = function() {
logo = true;
};
fenzhen.onRelease = function() {
logo = false;
};
fenzhen.onReleaseOutside = function() {
logo = false;
};
fenzhen.onMouseMove = function() {
if (logo) {
mousex = _xmouse;
mousey = _ymouse;
cx = mousex-shizhen._x;
cy = mousey-shizhen._y;
m1 = Math.atan2(cx, cy)*180/Math.PI;
//计算鼠标现在位置与元件Y轴的夹角
m2 = 180-m1;
//将夹角转换成分针的角度
fenzhen._rotation = m2;
//设置分针角度
shizhen._rotation = i*30+m2/12;
//时针旋转角度
fen = int(10*m2/6)/10;
//计算时间分
shi = i;
if (i<0) {
shi = 12+i;
}
//时
if (m2/360>=0.9955) {
i = i+1;
//此代码运行有瑕疵,逆时针转动有问题。如果要流畅运转不知怎么写代码。
}
jd = i*360+int(m2*10)/10;
//分针旋转角度(保留一位小数)
}
};
fenzhen.onEnterFrame = function() {
if ((prevr<50 && prevr>0) && (fenzhen._rotation<0 && fenzhen._rotation>-50)) {
i = i-1;
}
prevr = fenzhen._rotation;
//转速要超过帧频才能实现。
};
//逆时针旋转代码,要转快才可以实现。
看附件。
热心网友 时间:2024-02-26 05:19
我也只是初学者,不太能解答这个问题,不过你这个问题发到硬件板块似乎不合适,最好去软件版块问一下比较妥当,那里高手比较多