2 Replies Latest reply on Jul 8, 2008 11:52 AM by scottgroovez

    Loaded SWF & hitTest

    scottgroovez
      Hi,

      I have a problem with loaded SWF's and hitTests that use X & Y. We're using content that originally was loaded into a Shell SWF at 0,0. All hitTests worked fine.

      Now we're creating a new project where this content loads in a window area that is not at 0,0. Because hitTest using X & Y uses the Global scope these hitTests now do not work.

      Is there a solution to making the hitTest use the scope of itself? I've tried _lockroot but this didn't solve it. Or is there another solution?

      Regards,
      Scott
        • 1. Re: Loaded SWF & hitTest
          Level 7
          Scott,

          > Now we're creating a new project where this content loads in
          > a window area that is not at 0,0. Because hitTest using X & Y
          > uses the Global scope these hitTests now do not work.

          The MovieClip.hitTest() method doesn't really depend on scope -- unless
          I'm misunderstanding your use of the word -- but you might be facing an
          issue that could be addressed with the MovieClip.localToGlobal() or
          globalToLocal() methods.

          > Is there a solution to making the hitTest use the scope of itself?
          > I've tried _lockroot but this didn't solve it.

          The MovieClip._lockroot property, when set to true, instructs a loaded
          movie clip to interpret any references to _root (in its own code, that is)
          as if it *hadn't* been loaded into another SWF. It doesn't really affect
          the placement (x and y values) of visual objects on the stage.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Loaded SWF & hitTest
            scottgroovez Level 1
            Hi David,

            I managed to get it sorted. Had to use localToGlobal() as you suggested to work out an offset of the loaded SWF in relation to the parent shell. Not only that but the loaded SWF was being resized so had to take that into account when doing the calculations.

            Cheers,
            Scott