4 Replies Latest reply on Apr 27, 2006 10:55 PM by smillerd

    Image scrolling

      Greetings,

      Forgive me for my almost complete ignorance in actionscript, but I am trying to learn.

      I used some modified code from a tutorial to create this:

      http://www.journeyinoils.com/cov/neigh_plan.html

      What I need it to do is to only scroll when the mouse gets about 60 pixels from the sides or top or bottom, so the user can rollover the individual buildings without the large image constantly moving. Is this a possibility in Flash?

      If so, where could I get help in doing this? Thanks in advance for any help or direction.

      smiller
        • 1. Re: Image scrolling
          Level 7

          "smillerd" <webforumsuser@macromedia.com> wrote in message news:e2qtju$hak$1@forums.macromedia.com...
          > What I need it to do is to only scroll when the mouse gets about 60 pixels
          > from the sides or top or bottom, so the user can rollover the individual
          > buildings without the large image constantly moving. Is this a possibility in
          > Flash?

          I had to look at your code to see how it was set up. Since you want to use just the edges for scrolling then it really doesn't need
          the easing formula.

          1) Edit your stroke movieclip and put registration point for y at center instead of top so that it matches the x registration point
          (and the mosue calculations are the same then)
          2) Reposition the stroke movieclip on the stage after registration point is fixed in step 1
          3) enter the code below

          this.onEnterFrame = function()
          {
          if(_root.stroke.hitTest(_root._xmouse, _root._ymouse))
          {
          mapMoveX();
          mapMoveY();
          }
          }
          //*******************************************************************************
          function mapMoveX()
          {
          var mouseOffset = _root.stroke._xmouse;

          if (mouseOffset > 202)
          {
          panel._x -= (mouseOffset / 18);
          if (panel._x < -400)
          panel._x = -400;
          }
          else if(mouseOffset < -202)
          {
          panel._x -= (mouseOffset / 18);
          if (panel._x > -36)
          panel._x = -36;
          }
          }
          //*******************************************************************************
          function mapMoveY()
          {
          var mouseOffset = _root.stroke._ymouse;

          if (mouseOffset < -90)
          {
          panel._y += 12;
          if (panel._y > 75)
          panel._y = 75;
          }
          else if(mouseOffset > 90)
          {
          panel._y -= 12;
          if (panel._y < -194 )
          panel._y = -194;
          }
          }
          //*******************************************************************************
          I tested it. Seems to be working fine.
          hope that helps ya,
          tralfaz


          • 2. Re: Image scrolling
            Level 1
            Traflaz,

            A million thanks. Just what I needed to happen. I'd offer you my first born if he wasn't already in his mid twenties...

            If I may bother you with one more question: With this particular swf, is it possible to have the mouse cursor change to an arrow when it gets in the "zone", so the user knows the map will move that direction? If you know of a tutorial of this, that would be great.

            Thanks again for the quick and excellent help.

            smiller
            • 3. Re: Image scrolling
              Level 7

              "smillerd" <webforumsuser@macromedia.com> wrote in message news:e2rde0$88i$1@forums.macromedia.com...
              > Traflaz,
              >
              > A million thanks. Just what I needed to happen. I'd offer you my first born if
              > he wasn't already in his mid twenties...
              >
              > If I may bother you with one more question: With this particular swf, is it
              > possible to have the mouse cursor change to an arrow when it gets in the
              > "zone", so the user knows the map will move that direction? If you know of a
              > tutorial of this, that would be great.
              >
              > Thanks again for the quick and excellent help.
              >
              > smiller

              no problem, glad to help. This is same with small modification to use a custom cursor..
              tralfaz

              this.onEnterFrame = function()
              {
              if(_root.stroke.hitTest(_root._xmouse, _root._ymouse))
              {
              mapMoveX();
              mapMoveY();
              }
              else
              {
              moveZoneX = false;
              moveZoneY = false;
              }
              }
              //*******************************************************************************
              function mapMoveX()
              {
              var mouseOffset = _root.stroke._xmouse;
              moveZoneX = false;

              if (mouseOffset > 202)
              {
              panel._x -= (mouseOffset / 18);
              if (panel._x < -400)
              panel._x = -400;
              moveZoneX = true;
              }
              else if(mouseOffset < -202)
              {
              panel._x -= (mouseOffset / 18);
              if (panel._x > -36)
              panel._x = -36;
              moveZoneX = true;
              }
              }
              //*******************************************************************************
              function mapMoveY()
              {
              var mouseOffset = _root.stroke._ymouse;

              moveZoneY = false;
              if (mouseOffset < -90)
              {
              panel._y += 12;
              if (panel._y > 75)
              panel._y = 75;
              moveZoneY = true;
              }
              else if(mouseOffset > 90)
              {
              panel._y -= 12;
              if (panel._y < -194 )
              panel._y = -194;
              moveZoneY = true;
              }
              }
              //*******************************************************************************
              _root.onMouseMove = function()
              {
              if(moveZoneX || moveZoneY)
              {
              Mouse.hide();
              cursor_mc._visible = true;
              cursor_mc._x = _root._xmouse;
              cursor_mc._y = _root._ymouse;
              updateAfterEvent();
              }
              else
              {
              Mouse.show();
              cursor_mc._visible = false;
              }
              }
              //*******************************************************************************


              • 4. Re: Image scrolling
                Level 1
                Thanks again. I really appreciate it.

                Have a great weekend.

                smiller