3 Replies Latest reply on Jul 18, 2007 5:31 AM by BarryGee

    cursor hitTest

    BarryGee Level 1
      Hi.

      Is it possible to perform a hitTest with the cursor and a movieclip, not a movieclip and another movieclip. What i am trying to do is when the cursor is over a specific movieclip a custom cursor is used but when the cursor is not over the movieclip the normal system cursor is used. The codei have so far is attached below.

      All advice / hacks at my code are welcome.

      Barry.
        • 1. Re: cursor hitTest
          Level 7
          ++ Barry ++,

          > Is it possible to perform a hitTest with the cursor and
          > a movieclip, not a movieclip and another movieclip.

          You betcha. In fact, it's listed as "Usage 1" in the Help docs, while
          the movielip-to-movieclip version is listed as "Usage 2."

          > All advice / hacks at my code are welcome.

          No hacking necessary for this one. Just provide the x and y coordinates
          desired, and supply an optional instruction to use the testing clip's shape
          rather than its bounding box.

          > if (clearMC.hitTest(screen)) {

          if (clearMC.hitTest(_root._xmouse, _root._ymouse)) {

          That would supply the x and y coordinates of the mouse in relation to
          the Stage itself. The _root reference refers to the main timeline, which
          essentially is a movie clip, which is why the MovieClip._xmouse and
          MovieClip._ymouse properties may be accessed against it. To use clearMC's
          shape rather that its bounding box, add a thurd parameter and make it true.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: cursor hitTest
            BarryGee Level 1
            Hi David, thanks for the reply.

            I noticed after i had posted, that i had posted the old code from when i was using a movieclip hitTest on another movieclip. I changed this to the code attached.

            Barry.
            • 3. Re: cursor hitTest
              BarryGee Level 1
              working code: