0 Replies Latest reply on Nov 27, 2006 6:11 AM by Spindrift

    Problem with down scroll button in dynamic swf. Please help!

    Spindrift Level 1
      hi guys,

      thanks for checking out me post!

      i have created a flash movie that has a movieclip (sponsorship) containing another mc that is scrolled by an up and down button - this works perfectly.

      for another section of the movie i have a dynamic swf (overview) which used exactly the same code but only the down button works - the up button doesnt work at all...

      here is the syntax im using:

      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;
      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();
      };
      dragger.onMouseUp = function() {
      this.stopDrag();
      drag = false;
      };
      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();
      };
      bar.onMouseUp = function() {
      drag = false;
      };
      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();
      }
      };
      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);
      };
      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;
      };
      };

      ...and...

      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.rollOver = 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.rollOver = 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();

      you can check out the site at www.aaronscott.co.uk/scottmotorsport

      anyone got any ideas as to what i could do to fix this?

      thank you very much and i hope to hear from you.

      all the best,

      mark