3 Replies Latest reply on Jul 5, 2006 1:53 PM by Manu503

    Movie pause according to mouse position

    lhillyard
      Hi.

      I am trying to make an interactive flash menu of products. I want the entire flash movie to pause when the mouse is not over it. (I think it is disorienting to see it scrolling when it isn't being used.) When the mouse is over it, I want it to act as is.

      Here is a link to what I'm talking about:
      http://www.envirodirectory.com/chemtex

      Here is my current script:
      mouseX = _xmouse;
      menuX = menu._x;

      if (mouseX > 424) {
      diff = (mouseX-424)/150;
      }
      if (mouseX < 424) {
      diff = (424-mouseX)/150;
      }
      if (mouseX <= 424 && menuX <= 96) {
      setProperty("menu", _x, menuX+diff);
      }
      if (mouseX >= 424 && menuX >= -3120) {
      setProperty("menu", _x, menuX-diff);
      }
      if (menu._x >= 96) {
      menu._x = 96;
      } else if (menu._x <= -3120) {
      menu._x = -3120;
      }
      gotoAndPlay(2);

      Thanks!
        • 1. Re: Movie pause according to mouse position
          blemmo Level 1
          You could make the active area a movieclip, and use the hitTest() method to check if the mouse is over it. Then only do the scrolling when it returns true.

          hth,
          blemmo
          • 2. Re: Movie pause according to mouse position
            Level 7

            "lhillyard" <webforumsuser@macromedia.com> wrote in message
            news:e4d605$do1$1@forums.macromedia.com...
            > Hi.
            >
            > I am trying to make an interactive flash menu of products. I want the
            > entire
            > flash movie to pause when the mouse is not over it. (I think it is
            > disorienting to see it scrolling when it isn't being used.) When the
            > mouse is
            > over it, I want it to act as is.
            >
            > Here is a link to what I'm talking about:
            > <a target=_blank class=ftalternatingbarlinklarge
            > href=" http://www.envirodirectory.com/chemtex
            >
            > Here"> http://www.envirodirectory.com/chemtex
            >
            > Here</a> is my current script:
            > mouseX = _xmouse;
            > menuX = menu._x;
            >
            > if (mouseX > 424) {
            > diff = (mouseX-424)/150;
            > }
            > if (mouseX < 424) {
            > diff = (424-mouseX)/150;
            > }
            > if (mouseX <= 424 && menuX <= 96) {
            > setProperty("menu", _x, menuX+diff);
            > }
            > if (mouseX >= 424 && menuX >= -3120) {
            > setProperty("menu", _x, menuX-diff);
            > }
            > if (menu._x >= 96) {
            > menu._x = 96;
            > } else if (menu._x <= -3120) {
            > menu._x = -3120;
            > }
            > gotoAndPlay(2);
            >
            > Thanks!
            >




            "lhillyard" <webforumsuser@macromedia.com> wrote in message
            news:e4d605$do1$1@forums.macromedia.com...
            > Hi.
            >
            > I am trying to make an interactive flash menu of products. I want the
            > entire
            > flash movie to pause when the mouse is not over it. (I think it is
            > disorienting to see it scrolling when it isn't being used.) When the
            > mouse is
            > over it, I want it to act as is.
            >
            > Here is a link to what I'm talking about:
            > <a target=_blank class=ftalternatingbarlinklarge
            > href=" http://www.envirodirectory.com/chemtex
            >
            > Here"> http://www.envirodirectory.com/chemtex
            >
            > Here</a> is my current script:
            > mouseX = _xmouse;
            > menuX = menu._x;
            >
            > if (mouseX > 424) {
            > diff = (mouseX-424)/150;
            > }
            > if (mouseX < 424) {
            > diff = (424-mouseX)/150;
            > }
            > if (mouseX <= 424 && menuX <= 96) {
            > setProperty("menu", _x, menuX+diff);
            > }
            > if (mouseX >= 424 && menuX >= -3120) {
            > setProperty("menu", _x, menuX-diff);
            > }
            > if (menu._x >= 96) {
            > menu._x = 96;
            > } else if (menu._x <= -3120) {
            > menu._x = -3120;
            > }
            > gotoAndPlay(2);
            >
            > Thanks!
            >

            You need to update your script and get it into thie centrury.

            setProperty, though not depricated yet is sure to be some day.

            You should try something more like this:
            NOTE*** NOT TESTED

            menu.onRollOver = function() {
            this.onEnterFrame = function() {
            if (_root._xmouse > this._width / 2 &&
            this._x + this._width - 5 > Stage.width) {
            this._x -= 5;
            } else if (_root._xmouse <= this._width / 2 &&
            this._x + 5 < 0) {
            this._x += 5;
            }
            }
            }

            menu.onRollOut = function() {
            delete this.onEnterFrame;
            }

            You could even get trickier and have the rate at which the menu moves (5 in
            this case) be based on the current position of the mouse relative to the
            postion of the left and right sides of the Stage... so as you move your
            mouse closer to the middle it slows down. That would be done by finding the
            diff between _root._xmouse and Stage.width / 2 and using the result
            inversely.

            Amy


            • 3. Re: Movie pause according to mouse position
              Manu503
              @Amy:

              I need the same as lhillyard! But there is a problem with your code: menu.onRollOut = function() must appear within on/onClipEvent handler.

              Can anybody help me with this? Thanks.