Highlighted

scrollbar reset

Explorer ,
Jan 25, 2019

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

568

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

scrollbar reset

Explorer ,
Jan 25, 2019

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

569

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 25, 2019 0
Advisor ,
Jan 25, 2019

Copy link to clipboard

Copied

if you talks about the component UIScrollbar, then

just do myScrollbar.scrollPosition = 0;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0
Explorer ,
Jan 25, 2019

Copy link to clipboard

Copied

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();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0
Advisor ,
Jan 25, 2019

Copy link to clipboard

Copied

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;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0
Explorer ,
Jan 25, 2019

Copy link to clipboard

Copied

can i just add the code at the bottom of the other code or is there a specific place i need to add it in to ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0
Advisor ,
Jan 25, 2019

Copy link to clipboard

Copied

you should put this code in the button function when content is changed

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0
Explorer ,
Jan 25, 2019

Copy link to clipboard

Copied

sorry i tried and doesnt work can you please copy the code i used and insert the new add in code where it must go and copy and paste it in a reply for me please ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0
Advisor ,
Jan 25, 2019

Copy link to clipboard

Copied

Sorry I have no time, I'm at work.

just put the code when the new content is loaded/shown

be careful of the scope, don't know if this code is on the Frame 1 on in a class

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2019 0