5 Replies Latest reply on Feb 1, 2007 12:10 PM by Newsgroup_User

    hitTest

    Level 7
      I have an ifstatment, in which I would like to test if the mouse is over
      one of several MCs which I have set up as buttons in a dropdown. The
      thing is that I only went to trigger the rollout sequence if the mouse
      is on either one of the buttons, so I have to make sure it is off all of
      them. How would I make that condition so is check for several button?

      if(condition){
      //Start the rollOut actions

      }


      Thanks for any help!
      Brian

        • 1. Re: hitTest
          kglad Adobe Community Professional & MVP
          if you have buttons, btn1, btn2, btn3 and you want to check that the mouse is not on any of them (ie, is off all of them) use:

          • 2. Re: hitTest
            Level 7
            Hey KGlad,
            thanks a lot for the help.

            I now have the following and am having some issues with it:
            function subMenuOff(theBtn:MovieClip):Void{

            if(!nav1.production_menu.digital_btn.hitTest(_xmouse, _ymouse) &&
            !nav1.production_menu.video_btn.hitTest(_xmouse, _ymouse) &&
            !nav1.production_menu.events_btn.hitTest(_xmouse, _ymouse)){
            trace("subMenuOff on the Production side");


            }

            else if(!nav1.case_menu.case1_btn.hitTest(_xmouse, _ymouse) &&
            !nav1.case_menu.case2_btn.hitTest(_xmouse, _ymouse)){
            trace("subMenuOff on the Case Studies side");


            }
            }

            Somehow it keeps just triggering the Production side, regardless if I
            roll over the button on that side or not. What could that be? I am
            probably missing something....?

            I put a trace on all the buttons that just says trace(this), and so it
            seems that the right buttons trace, but I don't get the right part of
            the if to trigger?

            You can see the file in action here:
            http://www.agilitygraphics.com/clients/capitola/
            Production Services and Case Studies menues.

            Also, sometimes the one menu closes the other one.

            Thank you for the help!



            kglad wrote:
            > if you have buttons, btn1, btn2, btn3 and you want to check that the mouse is
            > not on any of them (ie, is off all of them) use:
            >
            >
            >
            >
            > if(!btn1.hitTest(_xmouse,_ymouse)&&!btn2.hitTest(_xmouse,_ymouse)&&!btn3.hitTest
            > (_xmouse,_ymouse)){
            > // rollout
            > }
            >
            • 3. Re: hitTest
              Level 7
              Here are some traces and it seems like the ifStatement gets confused...

              _level0.nav1.production_btn
              _level0.nav1.production_menu.events_btn
              subMenuOff on the Case Studies side
              _level0.nav1.production_menu.events_btn
              subMenuOff on the Production side
              _level0.nav1.production_btn
              _level0.nav1.production_menu.video_btn
              subMenuOff on the Production side
              _level0.nav1.case_studies_btn
              _level0.nav1.case_menu.case2_btn
              subMenuOff on the Production side
              _level0.nav1.case_menu.case2_btn
              subMenuOff on the Production side
              • 4. Re: hitTest
                kglad Adobe Community Professional & MVP
                theBtn has nothing to do with the code in your function. is it supposed to? and that code is attached to the main timeline, correct? and you're calling that function when the mouse is down, correct?
                • 5. Re: hitTest
                  Level 7
                  kglad, yeah, it should. And yeah, main timeline and no, onMouseOut.
                  Thank you so much for the help, and sorry for the duplicate, I was not
                  sure if you would still see that poste, since it was started yesterday.
                  I view these through Netscape and so I get no notifications on posts and
                  have to check back.

                  Button looks like this:

                  this.nav1.production_menu.digital_btn.onRollOver = function():Void {
                  trace(this);
                  };
                  this.nav1.production_menu.digital_btn.onRollOut = function():Void {
                  subMenuOff(this);
                  };


                  And that function:

                  //turn the submenus off
                  function subMenuOff(theBtn:MovieClip):Void{
                  //RollOver actions for the submenus
                  if(!nav1.production_menu.digital_btn.hitTest(_xmouse, _ymouse) &&
                  !nav1.production_menu.video_btn.hitTest(_xmouse, _ymouse) &&
                  !nav1.production_menu.events_btn.hitTest(_xmouse, _ymouse)){
                  trace("subMenuOff on the Production side");
                  //fuse to deactive the menu as appropriate
                  var prodMenuOff:Fuse = new Fuse();
                  prodMenuOff.label = "prodOpen"; // label is a convenience for
                  traceItems() calls.
                  prodMenuOff.autoClear = true; // set instance to self-destroy after
                  completion
                  prodMenuOff.push(
                  [
                  {delay:0.3, target:nav1.production_menu, _alpha:0, seconds:0.6,
                  ease:"easeOutQuad"},
                  {delay:0.3, target:nav1.production_btn, _alpha:100, seconds:0.6,
                  ease:"easeOutQuad", func:prodClose}
                  ]
                  );
                  prodMenuOff.start();

                  }

                  else if(!nav1.case_menu.case1_btn.hitTest(_xmouse, _ymouse) &&
                  !nav1.case_menu.case2_btn.hitTest(_xmouse, _ymouse)){
                  trace("subMenuOff on the Case Studies side");
                  //fuse to deactive the menu as appropriate
                  var caseMenuOff:Fuse = new Fuse();
                  caseMenuOff.label = "prodOpen"; // label is a convenience for
                  traceItems() calls.
                  caseMenuOff.autoClear = true; // set instance to self-destroy after
                  completion
                  caseMenuOff.push(
                  [
                  {delay:0.3, target:nav1.case_menu, _alpha:0, seconds:0.6,
                  ease:"easeOutQuad"},
                  {delay:0.3, target:nav1.case_studies_btn, _alpha:100, seconds:0.6,
                  ease:"easeOutQuad", func:caseClose}
                  ]
                  );
                  caseMenuOff.start();

                  }
                  }