# Scroll Movieclip - stop at certain point

**URL:** https://forum.kirupa.com/t/scroll-movieclip-stop-at-certain-point/227384
**Category:** flash
**Created:** [May 29, 2007, 8:14pm UTC](https://forum.kirupa.com/t/scroll-movieclip-stop-at-certain-point/227384 "2007-05-29T20:14:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![matm00](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/matm00/32/2487_2.png) [@matm00](https://forum.kirupa.com/u/matm00)
#### Post date: [May 29, 2007, 8:14pm UTC](https://forum.kirupa.com/t/scroll-movieclip-stop-at-certain-point/227384/1 "2007-05-29T20:14:52Z")

</div>

Hi. I figured out the code below to make a movie clip scroll up and down. However, the problem is that it will keep scrolling forever. Does anyone know how I can get it to stop at a minimum and maximum vertical height?

```auto

var scrollUp = function() {
    test_mc.onEnterFrame = function() {
        this._y -= 5;
    }
};
var scrollDown = function() {
    test_mc.onEnterFrame = function() {
        this._y += 5;
    }
};
scrollup_mc.onRollOver = function() {
    scrollUp();
};
scrollup_mc.onRollOut = function() {
    delete test_mc.onEnterFrame;
};
scrolldown_mc.onRollOver = function() {
    scrollDown();
};
scrolldown_mc.onRollOut = function() {
    delete test_mc.onEnterFrame;
};

```
