4 Replies Latest reply on Jun 27, 2008 9:07 AM by William Langley

    HitTest and settimeout button functions

    graham howe
      Hi All,

      I've searched the forum and not found an answer to the age old question of 'Why is my button sticking when fast mouse actions rollover the button?'.

      I've got a flash button in my html page, on fast mouse movement, the button sticks on the over state.
      So I embarked on a journey to try out the hittest and setimeout functions.

      My actions script:

      Please help

      my Download my .fla
        • 1. Re: HitTest and settimeout button functions
          William Langley Level 1

          On the surface it appears you're not using the hitTest() properly. You're really tracking the mouse location. Whether it's over the button, right? If so, that code should be:

          ...btn_mc.hitTest(_root._xmouse, _root._ymouse)
          • 2. Re: HitTest and settimeout button functions
            graham howe Level 1
            Thanks for replying!

            I've tried what you suggested, and... swiping past/over the button, leaving the button stuck on the hit state, she doesn't use the settimeout to reset the button state. Does this make sense (my ramblings?) ;-)

            thanks again
            • 4. Re: HitTest and settimeout button functions
              William Langley Level 1
              Well, it should be btn_mc.hitTest(_root._xmouse, _root._ymouse), but looking at your file I doubt that will do it.

              Your basic problem is that your button is nearly the size of your stage and Flash can't register mouse activity outside its stage. So, if you move the mouse out fast enough Flash still thinks the mouse is on the stage.

              You really only have 3 choices: Make the button small enough to register the onRollOut(); or use an interval to check for idle and trigger the mouse out whether they're out or not (see code below), or use javascript to tell Flash it no longer has the mouse (this is what they do with banners).

              var to;
              var mousePos = {};

              btn_btn.onRollOver = function() {
              mousePos.x = _root._xmouse;
              mousePos.y = _root._ymouse;
              to = setInterval(_root, "openWebsite", 3000);

              btn_btn.onRollOut = function() {

              function openWebsite() {
              if(mousePos.x==_root._xmouse && mousePos.y==_root._ymouse && btn_mc._currentframe>1){
              mousePos.x = _root._xmouse;
              mousePos.y = _root._ymouse;