Help with math for restricting movement to diagonal

HI
i’m trying to restrict the movement of a mc to the diagonal. so even if i click and drag it towards the x direction, it moves the corresponding distance on the diagonal which is, the 45 deg angle line.
same with the y direction…
so when i click and move the mouse haphazardly, all the object does is to follow it on the diagonal.
But i just cant figure out the math for it. i mean, theoretically i think i need to use the x-component of the mouse when its angle is < 45 and the y-component when its angle is > 45. but how do i find those angles in flash??

help me please…