flash actionscript:
:confused;
HI and thanks for reading:
I have a "wheel of fortune" type wheel, which I'm spinning with a button. The
wheel has some easing math on it which is causing havoc when spinning past
180*. I got it all to work when there were five sections in the wheel using
the following code:
var degEnd = 0;
_parent._parent.right_btn.onPress = function() {
var rotate = 0;
//Compensates for the passing from -179 to 180 in rotation
if (degEnd<=-144) {
degEnd = 144;
diffDeg = -72;
} else {
//Sets end rotation
degEnd = degEnd-72;
}
wheelparts_mc.onEnterFrame = function() {
//sets rotation speed and direction for the slice that crosses 180
if (degEnd == 144) {
//speed
rotate = rotate+diffDeg/6;
//easing
rotate = rotate*.5;
wheelparts_mc._rotation = wheelparts_mc._rotation+rotate;
wheeltext_mc._rotation = wheeltext_mc._rotation+rotate;
diffDeg = diffDeg-rotate;
//sets rotation speed and direction for the other slices
} else {
diffDeg = degEnd-wheelparts_mc._rotation;
//Speed
rotate = rotate+diffDeg/6;
//Easing
rotate = rotate*.5;
wheelparts_mc._rotation = wheelparts_mc._rotation+rotate;
wheeltext_mc._rotation = wheeltext_mc._rotation+rotate;
}
};
trace(degEnd);
};
For some reason this does NOT work when the wheel has 10 sections. It goes
crazy when it goes from 180* to 144*.
var degEnd = 0;
var rotate:Number;
_parent._parent.right_btn.onPress = function() {
rotate = 0;
//Compensates for the passing from -179 to 180 in rotation
if (degEnd <=-144) {
degEnd = 180;
diffDeg = -36;
} else {
//Sets end rotation
degEnd = degEnd-36;
}
wheelparts_mc.onEnterFrame = function() {
//sets rotation speed and direction for the slice that crosses 180
if (degEnd == 180) {
//speed
rotate = rotate+diffDeg/6;
//easing
rotate = rotate*.5;
wheelparts_mc._rotation = wheelparts_mc._rotation+rotate;
//wheeltext_mc._rotation = wheeltext_mc._rotation+rotate;
diffDeg = diffDeg-rotate;
//sets rotation speed and direction for the other slices
} else {
diffDeg = degEnd-wheelparts_mc._rotation;
//Speed
rotate = rotate+diffDeg/6;
//Easing
rotate = rotate*.5;
wheelparts_mc._rotation = wheelparts_mc._rotation+rotate;
//wheeltext_mc._rotation = wheeltext_mc._rotation+rotate;*/
}
};
};
Can anyone offer advice?