The problem is, flash only gives you the x,y coordinates of the cursor. So there is no direct way to measure the diagonal distance between the cursor and a MovieClip. In-order to do this, you have to use the Pythagorean Theorem.
- //For this example we are calculating from x:0 and y:0;
- function Calculate()
- var A = mouse.y;
- var B = mouse.x;
- var A2 = A * A;
- var B2 = B * B;
- var Hyp = A2+B2;
- var FinalResult = Math.round(Math.sqrt(Hyp));
- //FinalResult is the length of the Hypotenuse.
You need to login to post a comment.