First off, please ignore the styling.
Anyhow. What I’m working on is a spinning menu, and it’s sort of working, but there is a particular spot where in order to achieve the rotation that I want, the menu spins entirely around instead of just going the 3 degrees or whatever that it needs. I can’t quite figure out how to fix it.
Note how when you get to the 9 o’clock position it spins around in a weird fashion. Ideas?
The link: http://ragonadesign.com/spinner3.html
The code:
this.onEnterFrame = function() {
xDistance = this._xmouse-circle_mc._x;
yDistance = this._ymouse-circle_mc._y;
normalize = Math.abs(xDistance)+Math.abs(yDistance);
if ((xDistance>=0) & (yDistance>=0)) {
mouseDirection = 90*(yDistance/normalize);
} else if ((xDistance<=0) && (yDistance>=0)) {
mouseDirection = -90*(xDistance/normalize)+90;
} else if (((xDistance)<=0) && ((yDistance)<=0)) {
mouseDirection = -90*(yDistance/normalize)+180;
} else {
mouseDirection = 90*(xDistance/normalize)+270;
}
speed = 20;
i = (-mouseDirection-this.circle_mc._rotation)/speed;
h = ((-mouseDirection-this.circle_mc._rotation)+360)/speed;
if (mouseDirection<180) {
this.circle_mc._rotation += i;
this.circle_mc.menu1._rotation -= i;
this.circle_mc.menu2._rotation -= i;
this.circle_mc.menu3._rotation -= i;
this.circle_mc.menu4._rotation -= i;
this.circle_mc.blocker_mc._rotation -= i;
} else if (mouseDirection>180) {
this.circle_mc._rotation += h;
this.circle_mc.menu1._rotation -= h;
this.circle_mc.menu2._rotation -= h;
this.circle_mc.menu3._rotation -= h;
this.circle_mc.menu4._rotation -= h;
this.circle_mc.blocker_mc._rotation -= h;
}
this.label_mc.frame_txt.text = frameLabel;
this.label_mc.frame_txt2.text = frameLabel;
};
this.circle_mc.blocker_mc.onPress = function() {
startDrag(_root.circle_mc);
};
this.circle_mc.blocker_mc.onRelease = function() {
stopDrag();
};