Hello again, you guys. Maybe I should have updated my other thread but as they are completely different questions I thought I’d start a new one. So I have a mouse-rotated knob controlling an animation inside a movie clip. I have a problem with the timeline jumping backwards (or forwards, depending on the direction of the rotation) a frame when it gets to a certain point in the rotation of the knob… (If you would check the .fla and .swf you would see what I’m talking about).
You can access the files here:
And here is the problem code:
[LEFT]newRot = [COLOR=#993300]this[/COLOR].[COLOR=#993300]_rotation[/COLOR];
finalRot = newRot-prevRot;
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR]prevRot < [COLOR=#000000]0[/COLOR] && newRot > [COLOR=#000000]0[/COLOR][COLOR=#000000])[/COLOR] || [COLOR=#000000]([/COLOR]prevRot > [COLOR=#000000]0[/COLOR] && newRot < [COLOR=#000000]0[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
finalRot = finalRot *-[COLOR=#000000]1[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]Math[/COLOR].[COLOR=#993300]abs[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]Math[/COLOR].[COLOR=#993300]ceil[/COLOR][COLOR=#000000]([/COLOR]finalRot[COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR] > ani[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR]prevRot + [COLOR=#0000ff]', '[/COLOR] + newRot + [COLOR=#0000ff]', '[/COLOR] + finalRot[COLOR=#000000])[/COLOR];
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR]finalRot[COLOR=#000000])[/COLOR] > ani[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]_currentframe[/COLOR] == [COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]_totalframes[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]nextFrame[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]_currentframe[/COLOR] == [COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]_totalframes[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]_root[/COLOR].[COLOR=#000000]movie_mc[/COLOR].[COLOR=#993300]prevFrame[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
prevRot = newRot;
[/LEFT]
As you can see, the problem lies when the prevRot and newRot values have different signs (positive and negative), as it changes the result of the equation on the Math.abs part. That’s why i added that first IF statement, which is supposed to check if the signs are different, and if so, to change the sign of the finalRot value so it wont mess up the continuity of the reproduction… (I added the trace to check that, you can see the change in sign when it bumps)… But this IF statement is not working properly… Please, if you could help me with this, I’m really at my wit’s end and I need to turn this in tomorrow at the very least… PLEASE!! And thank you very much for your help in advance!