3 Replies Latest reply on Jan 5, 2008 10:03 PM by kglad

    Convert Movieclip scroller to dynamic text scroller

    Dave Blake Level 1
      I have code I borrowed that is set up to scroll a movie clip image. However, it doesn't work well if I replace the graphics with a text box as the scrolling becomes "jerky" as I think there is too much information for it to process with the complexity of the text. So I was hoping to change the scrolling content from a movie clip image with text to a dynamic textbox. But it will not function when I do that change. In this currrent setup, the movieclip instance name is "contentmain". I tried naming the instance of the dynamic textbox with that name, but no text shows up next to the scroller when I play the movie.

      Here's the code:
      scrolling = function () {

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

      // Setup easing event
      contentMain.desiredX = contentMain._y;
      contentMain.onEnterFrame = function() {
      this._y -= (this._y - this.desiredX) / 3;
      };

      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.desiredX = Math.round(dy*-1*moveVal+initContentPos);
      };
      };
      scrollFace.onMouseUp = function() {
      stopDrag();
      delete this.onMouseMove;
      };


      btnUp.onPress = function() {
      this.onEnterFrame = function() {
      if (contentMain._x+speed<maskedView._x) {
      if (scrollFace._x<=left) {
      scrollFace._x = left;
      } else {
      scrollFace._x -= speed/moveVal;
      }
      contentMain._x += speed;
      } else {
      scrollFace._x = left;
      contentMain._x = maskedView._x;
      delete this.onEnterFrame;
      }
      };
      };
      btnUp.onDragOut = function() {
      delete this.onEnterFrame;
      };
      btnUp.onRelease = function() {
      delete this.onEnterFrame;
      };
      btnDown.onPress = function() {
      this.onEnterFrame = function() {
      if (contentMain._x-speed>finalContentPos) {
      if (scrollFace._x>=right) {
      scrollFace._x = right;
      } else {
      scrollFace._x += speed/moveVal;
      }
      contentMain._x -= speed;
      } else {
      scrollFace._x = right;
      contentMain._x = 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();

      Any ideas?

      Thanks,
      Dave