# Help with math for restricting movement to diagonal

**URL:** <https://forum.kirupa.com/t/help-with-math-for-restricting-movement-to-diagonal/224125>\
**Category:** Uncategorized\
**Created:** [April 28, 2007, 9:36pm UTC](https://forum.kirupa.com/t/help-with-math-for-restricting-movement-to-diagonal/224125 "2007-04-28T21:36:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceblueflame](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@iceblueflame](https://forum.kirupa.com/u/iceblueflame)\
**Post date:** [April 28, 2007, 9:36pm UTC](https://forum.kirupa.com/t/help-with-math-for-restricting-movement-to-diagonal/224125/1 "2007-04-28T21:36:19Z")

</div>

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…
