1 Reply Latest reply on Nov 23, 2009 11:13 AM by kglad

    Target Drop Area

    Heath Bishop

      Up till now, I've always created a target drop area by using 4 coordinates. For example:

      If (mouse.x is <= -32 && mouse.x >= 32 && mouse.y <= -32 && mouse.y >= 32)



      I thought there might be a way to dynamically create the same above but with a circle (surrounding an MC) with a set radius.  The sole purpose of this circle is (like above) to test if the cursor is inside it to trigger an event. That way I only have to set a radius rather than 4 numbers like the above code. Plus I wouldn't have to keep track of whether a number is negative or positive. Just how wide from the center (radius) I want the circle to be.


      So how would I be able to do the above in AS2 or AS3?

        • 1. Re: Target Drop Area
          kglad Adobe Community Professional & MVP

          you can check the distance between any two points, including the distance between the mouse and the registration point of a movieclip.  you would use something like:



          // do whatever



          function distF(mc):Number{

          return (mc._x-_xmouse)*(mc._x-_xmouse)+(mc._y-_ymouse)*(mc._y-_ymouse);  // apply Math.sqrt if that's important