7 Replies Latest reply on Aug 4, 2009 3:38 AM by videostart

    switching from a vertical to horizontal scroller

    videostart Level 1

      I am attempting to modify an example file that I found from a vertical to horizontal scroller.

      I changed the movie clip to horizontal, but can someone help me to figure out

      what I need to change to get the arrows to scroll the movie clip horizontally.

       

      Please view the attached example....

       

      Thank you for your help!

        • 1. Re: switching from a vertical to horizontal scroller
          videostart Level 1

          Update...I got the movie clip to movie from left to right, but it doesn't seem to recognize how long the movie clip is now, because it stops before the whole movie clip is scrolled....see attached...

          Any ideas...??

          • 2. Re: switching from a vertical to horizontal scroller
            Ned Murphy Adobe Community Professional & MVP

            The only idea I can offer is you have to determine what boundary controls are used and set them relative to the _width of the scrolled item.  It sometimes takes a bit of head and pencil scratching to be able to visualize how to generically define the parameters.

             

            For instance, if the left edge (x=0) of the item is at x=0 pf the parent, then you know the limit for scrolling right is that x has to remain <= 0.  But for the other end of the item you want that to be stopped when its right edge hits the left edge of the viewable area.  That means the 0-edge of the item is almost the full _width of the item negative except for the width that is left showing.  So if you're scrolling to the right, the scrolling ends when x > 0, and if you're scrolling left the show stops at x < -1xitem.width + viewingArea._width

             

            Scratch your head over that... it's hard to explain, which is why a pencil comes in handy at times.

            1 person found this helpful
            • 3. Re: switching from a vertical to horizontal scroller
              videostart Level 1

              I think I see what you mean, but I don’t really get in the code where to set that?

              • 4. Re: switching from a vertical to horizontal scroller
                Ned Murphy Adobe Community Professional & MVP

                If you can show your code someone may be able to help.  It helps when you include your information in your posting rather than requiring people to look things up in files.  Uploading zip files to these forums somehow corrupts them, and beyond that, as a rule some people won't open files for a variety of reasons, not excluding avoiding potential viruses.

                • 5. Re: switching from a vertical to horizontal scroller
                  videostart Level 1

                  No problem!  I was thinking of swapping the x and y values, but i tried a couple times with no luck.

                   

                  Here is all the code that is in the file:

                   

                  fscommand("allowscale", "false");
                  bar.useHandCursor = dragger.useHandCursor=false;
                  space = 20;
                  friction = 0.9;
                  speed = 4;
                  y = dragger._y;
                  top = main._y;
                  bottom = main._y+mask_mc._height-main._height-space;

                   

                   

                  up_btn.onPress = function() {
                  myInterval = setInterval(moveDragger, 18, -1);
                  };
                  down_btn.onPress = function() {
                  myInterval = setInterval(moveDragger, 18, 1);
                  };
                  up_btn.onMouseUp = down_btn.onMouseUp=function () {
                  clearInterval(myInterval);
                  };
                  dragger.onMouseUp = function() {
                  this.stopDrag();
                  drag = false;
                  };
                  bar.onMouseUp = function() {
                  drag = false;
                  };

                  ///////////no x y values ////////////////////////

                  dragger.onPress = function() {
                  drag = true;
                  this.startDrag(false, this._x, this._parent.y, this._x, this._parent.y+this._parent.bar._height-this._height);
                  dragger.scrollEase();
                  };

                  bar.onPress = function() {
                  drag = true;
                  if (this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
                    this._parent.dragger._y = this._parent._ymouse;
                    this._parent.dragger._y = this._y+this._height-this._parent.dragger._height;
                  } else {
                    this._parent.dragger._y = this._parent._ymouse;
                  }
                  dragger.scrollEase();
                  };

                  moveDragger = function (d) {
                  if ((dragger._y>=y+bar._height-dragger._height && d == 1) || (dragger._y<=y && d == -1)) {
                    clearInterval(myInterval);
                  } else {
                    dragger._y += d;
                    dragger.scrollEase();
                    updateAfterEvent();
                  }
                  };

                  MovieClip.prototype.scrollEase = function() {
                  this.onEnterFrame = function() {
                    if (Math.abs(dy) == 0 && drag == false) {
                     delete this.onEnterFrame;
                    }
                    r = (this._y-y)/(bar._height-this._height);
                    dy = Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
                    main._y += dy;
                  };
                  };

                  • 6. Re: switching from a vertical to horizontal scroller
                    Ned Murphy Adobe Community Professional & MVP

                    I can't determine what is what in that code as far as item on the stage go, but changing the _y's to _x's would have been half the battle.  The other half would revolve around changing the _height's to _width's... basically anything relating to a vertical measure switches to being a horizontal.

                    1 person found this helpful
                    • 7. Re: switching from a vertical to horizontal scroller
                      videostart Level 1

                      Ok...I switched the x's to y's and the height's to widths.  Here is the code that I have now:

                      (The dragger seems to fly everywhere in the file now though....any help is greatly appreciated!)

                       

                      fscommand("allowscale", "false");

                      bar.useHandCursor = dragger.useHandCursor=false;

                      space = 20;

                      friction = 0.9;

                      speed = 4;

                      x = dragger._x;

                      top = main._x;

                      bottom = main._x+mask_mc._width-main._width-space;

                       

                       

                       

                      ///////////no x y values ////////////////////////

                       

                      up_btn.onPress = function() {

                           myInterval = setInterval(moveDragger, 18, -1);

                      };

                      down_btn.onPress = function() {

                           myInterval = setInterval(moveDragger, 18, 1);

                      };

                      up_btn.onMouseUp = down_btn.onMouseUp=function () {

                           clearInterval(myInterval);

                      };

                      dragger.onMouseUp = function() {

                           this.stopDrag();

                           drag = false;

                      };

                      bar.onMouseUp = function() {

                           drag = false;

                      };

                       

                      ///////////end no x y values ////////////////////////

                       

                      dragger.onPress = function() {

                           drag = true;

                           this.startDrag(false, this._y, this._parent.x, this._y, this._parent.s+this._parent.bar._width-this._width);

                           dragger.scrollEase();

                      };

                       

                      bar.onPress = function() {

                           drag = true;

                           if (this._parent._xmouse>this._x+this._width-this._parent.dragger._width) {

                                this._parent.dragger._x = this._parent._xmouse;

                                this._parent.dragger._x = this._x+this._width-this._parent.dragger._width;

                           } else {

                                this._parent.dragger._x = this._parent._xmouse;

                           }

                           dragger.scrollEase();

                      };

                       

                      moveDragger = function (d) {

                           if ((dragger._x>=x+bar._width-dragger._width && d == 1) || (dragger._x<=x && d == -1)) {

                                clearInterval(myInterval);

                           } else {

                                dragger._x += d;

                                dragger.scrollEase();

                                updateAfterEvent();

                           }

                      };

                       

                      MovieClip.prototype.scrollEase = function() {

                           this.onEnterFrame = function() {

                                if (Math.abs(dx) == 0 && drag == false) {

                                     delete this.onEnterFrame;

                                }

                                r = (this._x-x)/(bar._width-this._width);

                                dx = Math.round((((top-(top-bottom)r)-main._x)/speed)friction);

                                main._x += dx;

                           };

                      };