Skip to main content
Known Participant
January 25, 2019
Question

scrollbar reset

  • January 25, 2019
  • 1 reply
  • 926 views

hi i find after reading a page that i needed to scroll, stays in the position were i left it, thus the info page i scrolled may be in the middle or near the end and then i go to another page and when i return the info page is still in the exact same place/position that i had read up to.

is there a way to reset the scrollbar position to the top again so that it would be as if the info page had'nt been read at all.

thanks.

This topic has been closed for replies.

1 reply

Robert Mc Dowell
Legend
January 25, 2019

if you talks about the component UIScrollbar, then

just do myScrollbar.scrollPosition = 0;

Known Participant
January 25, 2019

heres my existing code : were do i add it, to make the scrollposition = 0

scrolling = function () {

    var scrollHeight:Number = scrollTrack1._height;

    var contentHeight:Number = term2._height;

    var scrollFace1Height:Number = scrollFace1._height;

    var maskHeight:Number = maskedView1._height;

    var initPosition:Number = scrollFace1._y=scrollTrack1._y;

    var initContentPos:Number = term2._y;

    var finalContentPos:Number = maskHeight-contentHeight+initContentPos;

    var left:Number = scrollTrack1._x;

    var top:Number = scrollTrack1._y;

    var right:Number = scrollTrack1._x;

    var bottom:Number = scrollTrack1._height-scrollFace1Height+scrollTrack1._y;

    var dy:Number = 0;

    var speed:Number = 95;

    var moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFace1Height);

   

    scrollFace1.onPress = function() {

        var currPos:Number = this._y;

        startDrag(this, false, left, top, right, bottom);

        this.onMouseMove = function() {

            dy = Math.abs(initPosition-this._y);

            term2._y = Math.round(dy*-1*moveVal+initContentPos);

        };

    };

    scrollFace1.onMouseUp = function() {

        stopDrag();

        delete this.onMouseMove;

    };

    btnUp1.onPress = function() {

        this.onEnterFrame = function() {

            if (term2._y+speed<maskedView1._y) {

                if (scrollFace1._y<=top) {

                    scrollFace1._y = top;

                } else {

                    scrollFace1._y -= speed/moveVal;

                }

                term2._y += speed;

            } else {

                scrollFace1._y = top;

                term2._y = maskedView1._y;

                delete this.onEnterFrame;

            }

        };

    };

    btnUp1.onDragOut = function() {

        delete this.onEnterFrame;

    };

    btnUp1.onRelease = function() {

        delete this.onEnterFrame;

    };

    btnDown1.onPress = function() {

        this.onEnterFrame = function() {

            if (term2._y-speed>finalContentPos) {

                if (scrollFace1._y>=bottom) {

                    scrollFace1._y = bottom;

                } else {

                    scrollFace1._y += speed/moveVal;

                }

                term2._y -= speed;

            } else {

                scrollFace1._y = bottom;

                term2._y = finalContentPos;

                delete this.onEnterFrame;

            }

        };

    };

    btnDown1.onRelease = function() {

        delete this.onEnterFrame;

    };

    btnDown1.onDragOut = function() {

        delete this.onEnterFrame;

    };

   

    if (contentHeight<maskHeight) {

        scrollFace1._visible = false;

        btnUp1.enabled = false;

        btnDown1.enabled = false;

    } else {

        scrollFace1._visible = true;

        btnUp1.enabled = true;

        btnDown1.enabled = true;

    }

};

scrolling();

Robert Mc Dowell
Legend
January 25, 2019

This is not the UIScrollBar component, but just a MovieClip.

so it should be initPosition = scrollTrack1._y;

if you want also the content reset

initContentPos = term2._y;