hi my code is bugged …
I want my line (which does) follow the mouse, like a dial.
I have converted the degrees into a percentage, so that when the percentage of the rotation reaches 100%, my script counts one revolution, and adds it to its ‘counter’… it kind of works, but sometimes it gets lost and if I go too fast: it misses the revolution count …
here is my code (with the line being ‘line’ as an MC)…
var degrees:Number = 0;
fixedX = line._x;
fixedY = line._y;
var radians:Number;
var angles:Number;
var counter:Number = 0;
var revolution:Number = 0;
var Last:Number = 0;
var percent:Number = 0;
onEnterFrame = function()
{
radians = Math.atan2(_ymouse-fixedY,_xmouse-fixedX);
angles = radians*180/Math.PI;
angles += 90;
line._rotation = angles ;
percent = Math.round(((angles+90)/360)*100);
angels.text = percent;
if (percent > Last)
{
counter = percent;
last.text = "last percent " + Last;
counta.text = "counter "+counter;
Last = percent+1;
if (counter >= 100)
{
revolution ++;
counter -= percent;
Last = 0;
}
}
rev.text = "revs = " + revolution;
}
Any help would be appreciated!