# Drag and scroll PLEASE HELP im desperate!

**URL:** <https://forum.kirupa.com/t/drag-and-scroll-please-help-im-desperate/241458>\
**Category:** flash\
**Created:** [October 14, 2007, 11:20am UTC](https://forum.kirupa.com/t/drag-and-scroll-please-help-im-desperate/241458 "2007-10-14T11:20:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crystalmedia](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@crystalmedia](https://forum.kirupa.com/u/crystalmedia)\
**Post date:** [October 14, 2007, 11:20am UTC](https://forum.kirupa.com/t/drag-and-scroll-please-help-im-desperate/241458/1 "2007-10-14T11:20:53Z")

</div>

a script that does this:  
movieClip clicked = start drag  
if it is dragged to the LEFT 100pixels it stops drag and scrolls to the left that is -800pixels if it is dragged to the RIGHT 100pixels it stops drag it scrolles +800pixels.

movieClip on release = stop drag  
it returns to its position before dragging.

I made this so far (DOESN’T WORK):

```auto
stop();
background.onPress = function () {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
        this.startDrag();
        }
    mouseX= _xmouse;
    onMouseMove = function () {
    mouseX2 = mouseX - _xmouse;
    if (mouseX2 > 100) {
    this.stopDrag();
    _root.lokacija1 = _root.background.targetx = background._x - Stage.width;
    mouseX= 0;
    mouseX2 = 0;
    play();
    } else if (mouseX2 < -100) {
    this.stopDrag();
    _root.lokacija1 = _root.background.targetx = background._x + Stage.width;
    mouseX = 0;
    mouseX2 = 0;
    play();
    }
    }
}

background.onRelease = function () {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
        this.stopDrag();
        delete (mouseX2);
        mouseX = 0;
        mouseX2 = 0;
        }
}

```
