10 Replies Latest reply on Apr 29, 2008 1:55 PM by kglad

    scrolling bar longer when imported

    micgamb
      Hallo everybody I have a very annoying problem with a movieclip.
      I have created a scrolling bar with some button attached and it works fine. When I open the related swf It is fine. The problem starts when I import it in my main .fla inside a MovieClip Holder. the scrolling bar is longer than the one that I can see in the single swf. What can I do?

      the site is www.studiosimultaneo.com and if yo go inn the section "portfolio" you can see the scrolling bar

      thank yo so much
        • 1. Re: scrolling bar longer when imported
          kglad Adobe Community Professional & MVP
          you would do well to read a tutorial about making a scrollbar.
          • 2. Re: scrolling bar longer when imported
            micgamb Level 1
            Could you suggest me one?? but, in your opinion, what do I do wrong ??
            thank you


            • 3. Re: scrolling bar longer when imported
              kglad Adobe Community Professional & MVP
              there's no logic behind your scrollbar settings. it looks like you "discovered" something that worked for that one swf and movieclip. and, if that's so, you can be sure it won't work if anything changes.

              but you might be able to salvage that one scrollbar for that one movieclip if you use

              this._lockroot=true;

              in your swf with the scrollbar.

              in the long run, you're better served by learning how to make a custom scrollbar:

              http://www.kirupa.com/developer/flash8/scrollbar.htm
              • 4. Re: scrolling bar longer when imported
                micgamb Level 1
                Thank you I did follow the tutorial that you gave me. It is actually very. If I follow the example it works but I cannot work it out if I have to use an Horizontal (x) bar and I just need the scroolbar.

                The code from the tutorial was:

                scrolling = function () {
                var scrollHeight:Number = scrollTrack._height;
                var contentHeight:Number = contentMain._height;
                var scrollFaceHeight:Number = scrollFace._height;
                var maskHeight:Number = maskedView._height;
                var initPosition:Number = scrollFace._y=scrollTrack._y;
                var initContentPos:Number = contentMain._y;
                var finalContentPos:Number = maskHeight-contentHeight+initContentPos;
                var left:Number = scrollTrack._x;
                var top:Number = scrollTrack._y;
                var right:Number = scrollTrack._x;
                var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;
                var dy:Number = 0;
                var speed:Number = 10;
                var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);

                scrollFace.onPress = function() {
                var currPos:Number = this._y;
                startDrag(this, false, left, top, right, bottom);
                this.onMouseMove = function() {
                dy = Math.abs(initPosition-this._y);
                contentMain._y = Math.round(dy*-1*moveVal+initContentPos);
                };
                };
                scrollFace.onMouseUp = function() {
                stopDrag();
                delete this.onMouseMove;
                };
                btnUp.onPress = function() {
                this.onEnterFrame = function() {
                if (contentMain._y+speed<maskedView._y) {
                if (scrollFace._y<=top) {
                scrollFace._y = top;
                } else {
                scrollFace._y -= speed/moveVal;
                }
                contentMain._y += speed;
                } else {
                scrollFace._y = top;
                contentMain._y = maskedView._y;
                delete this.onEnterFrame;
                }
                };
                };
                btnUp.onDragOut = function() {
                delete this.onEnterFrame;
                };
                btnUp.onRollOut = function() {
                delete this.onEnterFrame;
                };
                btnDown.onPress = function() {
                this.onEnterFrame = function() {
                if (contentMain._y-speed>finalContentPos) {
                if (scrollFace._y>=bottom) {
                scrollFace._y = bottom;
                } else {
                scrollFace._y += speed/moveVal;
                }
                contentMain._y -= speed;
                } else {
                scrollFace._y = bottom;
                contentMain._y = finalContentPos;
                delete this.onEnterFrame;
                }
                };
                };
                btnDown.onRelease = function() {
                delete this.onEnterFrame;
                };
                btnDown.onDragOut = function() {
                delete this.onEnterFrame;
                };

                if (contentHeight<maskHeight) {
                scrollFace._visible = false;
                btnUp.enabled = false;
                btnDown.enabled = false;
                } else {
                scrollFace._visible = true;
                btnUp.enabled = true;
                btnDown.enabled = true;
                }
                };
                scrolling();




                And I have tried to change the Height with the Width and the Y with The X like this:
                scrolling = function () {
                var scrollWidth:Number = scrollTrack._width;
                var contentWidth:Number = contentMain._width;
                var scrollFaceWidth:Number = scrollFace._width;
                var maskWidth:Number = maskedView._height;
                var initPosition:Number = scrollFace._x=scrollTrack._x;
                var initContentPos:Number = contentMain._x;
                var finalContentPos:Number = maskWidth-contentWidth+initContentPos;
                var left:Number = scrollTrack._x;
                var top:Number = scrollTrack._y;
                var right:Number = scrollTrack._x;
                var bottom:Number = scrollTrack._width-scrollFaceWidth+scrollTrack._x;
                var dy:Number = 0;
                var speed:Number = 10;
                var moveVal:Number = (contentWidth-maskWidth)/(scrollWidth-scrollFaceWidth);

                scrollFace.onPress = function() {
                var currPos:Number = this._y;
                startDrag(this, false, left, top, right, bottom);
                this.onMouseMove = function() {
                dy = Math.abs(initPosition-this._y);
                contentMain._x = Math.round(dy*-1*moveVal+initContentPos);
                };
                };
                scrollFace.onMouseUp = function() {
                stopDrag();
                delete this.onMouseMove;
                };

                the contents are sliding from left to ride the But the scrollbar goes from top to bottom. I really want to understand how it works. the tutorial is very clear and I did follow it very carefully.
                Would you help me?

                Thank you
                • 5. Re: scrolling bar longer when imported
                  kglad Adobe Community Professional & MVP
                  the definition you have for bottom should be the definition of right. bottom should be the same as top.
                  • 6. Re: scrolling bar longer when imported
                    micgamb Level 1
                    I did try all the combinations like:

                    var left:Number = scrollTrack._x;
                    var top:Number = scrollTrack._y;
                    var right:Number = scrollTrack._y;
                    var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._y;

                    var left:Number = scrollTrack._y;
                    var top:Number = scrollTrack._x;
                    var right:Number = scrollTrack._x;
                    var bottom:Number = scrollTrack._height-scrollFaceHeight+scrollTrack._x;

                    but it is not working...I am sorry to bother you but could you point out to where is the problem so I could understand how to solve

                    thank you for your precious help
                    • 8. Re: scrolling bar longer when imported
                      micgamb Level 1
                      now the bar slights horizontal... but the objects just stopped from sliding..
                      Thank you
                      • 9. Re: scrolling bar longer when imported
                        micgamb Level 1
                        I have done it!! after watching the code for hours with your precious help it worked. I have imported in main main frame and it is no longer than the contents anymore!!

                        thank yo so much
                        • 10. Re: scrolling bar longer when imported
                          kglad Adobe Community Professional & MVP
                          you're welcome.