8 Replies Latest reply on Nov 27, 2006 4:19 PM by Mister Peanut

    Scrolling Menu

    Mister Peanut Level 1
      Hi all,

      if anyone could point me in the right direction, I think I have a simple problem. I have a scrolling menu graphic containing buttons. I have the scrolling function working well, but am trying to make it stop when the graphic scrolls to its ends. I have surrounded my script in an if statement so that the code only executes when my menu_mc reaches the end. This doesn't work.

      Here is the code I am using:

      _root.onEnterFrame = function () {
      if (menu_mc._x > 0 && menu_mc._x<675){
      menu_mc._x = menu_mc._x + (0.5 * Stage.width - _root._xmouse)/10;
      }
      }

      my menu_mc is behind a mask, and is 675 pixels wide.
      Not sure what my problem is, I have difficulty with AS. Do I need an event listener to listen to when my mc goes beyond certain boundaries? If so, could someone help me with how to use this?

      Cheers for any tips.

      P
        • 1. Re: Scrolling Menu
          Level 7
          Not sure what you are trying to do. Is this supposed to be a menu
          oscillating left to right based on mouse position?

          Anyhow, based on your condition if _x is under 0 or above 675, it stops
          working. Your calculation for the new _x might allow _x to go negative or
          above 675, so you have to make sure it doesn't...

          I'm not sure of what you are trying to do so this might not be what you're
          looking for...

          _root.onEnterFrame = function() {
          if (menu_mc._x >= 0 && menu_mc._x <= 675) {
          var newX = menu_mc._x+(0.5*Stage.width-_root._xmouse)/10 ;
          if ( newX < 0 ) newX = 0 ;
          if ( newX > 675 ) newX = 675 ;
          menu_mc._x = newX ;
          }
          };


          "Mister Peanut" <webforumsuser@macromedia.com> wrote in message
          news:ejl5ni$1f0$1@forums.macromedia.com...
          > Hi all,
          >
          > if anyone could point me in the right direction, I think I have a simple
          > problem. I have a scrolling menu graphic containing buttons. I have the
          > scrolling function working well, but am trying to make it stop when the
          > graphic
          > scrolls to its ends. I have surrounded my script in an if statement so
          > that
          > the code only executes when my menu_mc reaches the end. This doesn't
          > work.
          >
          > Here is the code I am using:
          >
          > _root.onEnterFrame = function () {
          > if (menu_mc._x > 0 && menu_mc._x<675){
          > menu_mc._x = menu_mc._x + (0.5 * Stage.width - _root._xmouse)/10;
          > }
          > }
          >
          > my menu_mc is behind a mask, and is 675 pixels wide.
          > Not sure what my problem is, I have difficulty with AS. Do I need an
          > event
          > listener to listen to when my mc goes beyond certain boundaries? If so,
          > could
          > someone help me with how to use this?
          >
          > Cheers for any tips.
          >
          > P
          >


          • 2. Re: Scrolling Menu
            Mister Peanut Level 1
            Thanks for the quick reply.

            I will explain what I want to do a little more clearly.
            My goal is to have a scrolling graphic with buttons on it. As you move the mouse left, the graphic moves right. As you move the mouse right, the graphic moves left. This is a very common menu style; I have seen it on many websites. using this code alone:

            _root.onEnterFrame = function () {
            menu_mc._x = menu_mc._x + (0.5 * Stage.width -_root._xmouse)/10;
            }

            I get what I want, except my menu_mc continues to scroll indefinitely. All I want to do is have the menu_mc stop scrolling when it reaches its edge.

            So, using the code that you gave me, the menu stops scrolling left when it reaches the rightmost edge, but then it no longer works when I move the mouse back over the menu_mc to scroll right.

            I am confused, I will keep trying to work it out.

            P
            • 3. Re: Scrolling Menu
              Level 7
              Do you have a sample online that I can look at?

              The code I had sent you was with:
              a menu_mc 675px wide with the registration of this mc being in the center.
              When you move the mouse left the menu_mc moves right and vice versa. With
              the registration at the center the menu stops scrolling when its center
              reaches 0px on the main timeline or 675px. So you end up seeing half of the
              mc on the right or the left side of the stage.

              http://www.guevara.net/forums/

              JG

              "Mister Peanut" <webforumsuser@macromedia.com> wrote in message
              news:ejlgbb$dk9$1@forums.macromedia.com...
              > Thanks for the quick reply.
              >
              > I will explain what I want to do a little more clearly.
              > My goal is to have a scrolling graphic with buttons on it. As you move
              > the
              > mouse left, the graphic moves right. As you move the mouse right, the
              > graphic
              > moves left. This is a very common menu style; I have seen it on many
              > websites.
              > using this code alone:
              >
              > _root.onEnterFrame = function () {
              > menu_mc._x = menu_mc._x + (0.5 * Stage.width -_root._xmouse)/10;
              > }
              >
              > I get what I want, except my menu_mc continues to scroll indefinitely.
              > All I
              > want to do is have the menu_mc stop scrolling when it reaches its edge.
              >
              > So, using the code that you gave me, the menu stops scrolling left when it
              > reaches the rightmost edge, but then it no longer works when I move the
              > mouse
              > back over the menu_mc to scroll right.
              >
              > I am confused, I will keep trying to work it out.
              >
              > P
              >


              • 4. Re: Scrolling Menu
                Mister Peanut Level 1
                Ahhh, Thank you, Jose.

                It was the registration point that had me thrown off. I changed it to centre, and it works how I would like it to. It all makes sense now!

                Cheers,
                P
                • 5. Re: Scrolling Menu
                  Level 7
                  I'm glad you got it to work :-)

                  JG

                  "Mister Peanut" <webforumsuser@macromedia.com> wrote in message
                  news:ejsose$mk4$1@forums.macromedia.com...
                  > Ahhh, Thank you, Jose.
                  >
                  > It was the registration point that had me thrown off. I changed it to
                  > centre, and it works how I would like it to. It all makes sense now!
                  >
                  > Cheers,
                  > P


                  • 6. Re: Scrolling Menu
                    Mister Peanut Level 1
                    All right. Second stab at a new problem. (there was an error after hitting reply, and my last message was lost...)

                    The menu works fine now, and I have named it scroller.swf. What I want to do is load scroller.swf into another swf. I have used loadMovie to do this. No problems here. I can load the movie fine into my other swf file, except I'm getting one frustrating problem; the center of my scroller.swf changes to the center of my stage. so now, the scroller reads the mouse position of the new stage, and not the scroller.swf stage like I want it to.

                    I have used _lockroot = true(); with success in the past to make sure my swf retains all of its own functionality, however, this is not working as it usually does. Is there something obvious that I'm doing wrong? I have tried changing the registration point of the movie container I am loading scroller.swf into, and tried changing the center of my original file as well. Nothing seems to take the center off of my new swf, and change it to my loaded scroller.swf.

                    Any suggestions greatly appreciated.

                    P
                    • 7. Re: Scrolling Menu
                      Mister Peanut Level 1
                      Okay, I am gradually working my way through this problem, but I still need a little help. I have readjusted the numbers, and it seems to be working well. I am no longer loading scroller.swf into an empty movie clip. I have the FLV player and the scroller in different layers in the same swf. This is the code that works:

                      _lockroot = true();



                      _root.onEnterFrame = function() {
                      if (menu_mc._x >= 115 && menu_mc._x <= 860) {
                      var newX = menu_mc._x+(0.5*1300-_root._xmouse)/10 ; //Stage.width-_root 1300 = half of 1300 is centre point of scroll action.
                      if ( newX < 115 ) newX = 115 ;//115 adjusts the right side of clip
                      if ( newX > 860 ) newX = 860 ;//860 adjusts the left side of clip
                      menu_mc._x = newX ;
                      }
                      }

                      In order to stop the scrolling action from occurring when the mouse was not over the menu_mc, I tried adding to the first line of script:

                      menu_mc.onRollOver = function(){

                      // with my code above placed here

                      }

                      This, however, has removed the function of the buttons, but has retained the scrolling action. If anyone has any ideas as to why the buttons no longer work, I'd greatly appreciate it!

                      P
                      • 8. Re: Scrolling Menu
                        Mister Peanut Level 1
                        Please, if anyone can point me in the right direction, I'm still stuck on this.

                        Cheers,

                        P