5 Replies Latest reply on May 8, 2006 1:54 PM by Peter Lorent

    need help with hitTest

    mapnapkin
      How would I go about stopping the onResize function when the two MCs collide.
      heres my example page http://www.boogiestick.com/flash/

      heres my code so far

      Stage.scaleMode = "noScale";
      Stage.align = "LT";

      //REPOSITION MCs==================================
      MainArt._x = 0;
      MainArt._y = Stage.height;
      SignalNav._x = Stage.width-(Stage.width*.1);
      SignalNav._y = Stage.height*.15;

      stageListener = new Object();
      stageListener.onResize = function ()
      {
      SignalNav._x = Stage.width-(Stage.width*.1);
      SignalNav._y = Stage.height*.15;
      MainArt._x = 0;
      MainArt._y = Stage.height;
      }
      Stage.addListener(stageListener);
      //================================================

      //DETECT COLISION=================================
      if (SignalNav.hitTest(MainArt._x,MainArt._y,true)){
      stageListener.onResize = null;
      }


      its not working and I don't understand

      I've also uploaded my flash file. (flash 8)
      here - http://www.boogiestick.com/flash/resize.fla

      What am I doing wrong, is the detection code incorrect.

      thanks for any help
      Dm
        • 1. Re: need help with hitTest
          Peter Lorent Level 2
          The hitTest() doesn't work as expected because the registration points of the mc's are:
          - for MainArt in the bottomleft corner
          - for SignalNav in the topright corner.
          doubleclick the mc's on the stage and check it. You need to either reset the registration points or account for the registration point in your hitTest.
          Looping over the frame is not the way to go. Just use an interval to test for the collision. The attached script works (but it tests hitting of the bounding boxes).

          • 2. Re: need help with hitTest
            mapnapkin Level 1
            wow.... it worked, I've been trying to do that for about five days.

            I'm not sure what Action Script is closes to as far as language but is there a way to have the removeListener a loop or While so it only stops the reposition while the MCs re touching..

            you know I think I just came up with the solution
            If i have two stage listeners, one with invisible MCs that don't stop repositioning..

            thanks for the help
            • 3. need help with hitTest
              mapnapkin Level 1
              OK... my plan did not work..

              how can I get it to start the reposition when the onresize is stretched backout.
              right now if you shrink your browser the MCs hit and the onResize stops but when you stretch the browser back out I would like the MCs to be able to reposition as long as they dont touch..

              heres wat I tried
              two onResize functions, one set of 'Bump MCs' Alpha 0% that don't stop onResize for the tester and the second visible MCs that stop when the Bump MCs are touching
              note the 'if else' statement.. it no worky

              thanks again
              • 4. Re: need help with hitTest
                mapnapkin Level 1
                thank you so much " LuigiL"
                I got everything working perfect... I can't believe it...
                • 5. Re: need help with hitTest
                  Peter Lorent Level 2
                  You're welcome.