Just add 360 that should do it. But I wander if in your code you have if
(angle << 0) shouldn't that be if (angle < 0)???

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allandt
Bik-Elliott (Receptacle)
Sent: Tuesday, February 05, 2008 11:11 AM
To: flashcoders
Subject: [Flashcoders] urgent angle problem

hi guys

i have a problem that i need to sort out - i have a script that  
checks to see where the mouse pointer is in relation to a point of  
origin and then selects which frame from a group of 9 to show

the problem i'm having is that if the angle is above 180 degrees, it  
swaps to negative numbers back down to 0 (go to http://www. 
19.5degs.com/element/215.php to see an example - in particular watch  
the text frame as you move) and i need to figure out how to make it a  
full 360

i've tried

        if (angle<<0) {
                angle = (-1*angle)+180;
        }

but that's not right

here is my code

//image frame selector
function changeFrame(clip:MovieClip, angle:Number):Void {

        // frame is receiving a wrong number above 180 degrees here
        // there are 9 frames so i want each frame to have 40 degrees (hence

angle/40)
        var frame:Number = Math.round(angle/40);

        // visibleClip is a variable set on all clips (set in the mousemove

below) to tell my script which clip is visible to make it invisible  
without having to loop through the other clips when there's a change
        clip[clip.visibleClip]._visible = false;
        clip["p"+frame]._visible = true;
        clip.visibleClip = ["p"+frame];

}

//mouse follower
var mouseListener:Object = new Object();
mouseListener.lookAt = function(clip:MovieClip, originX:Number,  
originY:Number, watchX:Number, watchY:Number):Void {

        var adjside:Number = watchX - originX;
        var oppside:Number = -1*(watchY - originY);
        var angle:Number = Math.atan2(oppside, adjside); // in radians
        var angle:Number = Math.round(angle/Math.PI*180); // convert to
degrees
        var angle:Number = -1*(angle); // invert
        changeFrame(clip, angle);

}
mouseListener.onMouseMove = function () {

        var watchX:Number = _xmouse;
        var watchY:Number = _ymouse;
        
        // there are 8 images that are trying to do this
        for (var i:Number=1; i<9; i++) {
                var thisPerson:MovieClip = content_mc["person"+i];
                this.lookAt(thisPerson, thisPerson._x, thisPerson._y,  
_root._xmouse, _root._ymouse);
        }
};
Mouse.addListener(mouseListener);


hope you can help
alz


Allandt Bik-Elliott
Receptacle
t  01920 413 947  |  m  07970 718 545
e [EMAIL PROTECTED]

This e-mail is confidential and may be privileged. It is for the use  
of the named recipient(s) only. If you have received it in error,  
please notify us immediately. Please do not copy or disclose its  
contents to anyone, and delete it from your computer systems. Please  
note that information sent by e-mail can be corrupted. This e-mail  
has been prepared using information believed by the author to be  
reliable and accurate, but the Company makes no warranty as to its  
contents. Any opinions expressed are those of the author and do not  
necessarily reflect the opinions of the Company.


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to