0 Replies Latest reply on Sep 1, 2006 3:12 AM by Spindrift

    Coding issue with scrollbar up button

    Spindrift Level 1
      Hi all,

      I've made a scrollbar using a Kirupa tutorial for Flash 8 http://www.kirupa.com/developer/flash8/scrollbar.htm

      I have several of these on my site, scrolling certain movie clips for certain pages but for some reason, there is a severe coding issue with the 'up' button and I can't understand it as the Kirupa tutorial one works absolutely fine.

      If you check out http://spindriftmedia.com/clients/snowy/snowy.php and select the say the 'profile' section, if before you do any scrolling, just press the 'scroll up' button. For some reason, the text goes really blurred and scrolls to way past the bottom of the movie clip. The slider and down button behave perfectly though.

      This is the code I'm using:

      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.onRelease = 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();
      Do you by any chance know what is causing this problem? If you need an fla, I can upload one for you to check out.

      Thank you very much and I hope to hear from you.

      Take care,

      Mark