# Object movement

**URL:** <https://forum.kirupa.com/t/object-movement/320669>\
**Category:** Uncategorized\
**Created:** [March 29, 2011, 10:14pm UTC](https://forum.kirupa.com/t/object-movement/320669 "2011-03-29T22:14:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harrington](https://avatars.discourse-cdn.com/v4/letter/h/ac8455/32.png) [@Harrington](https://forum.kirupa.com/u/Harrington)\
**Post date:** [March 29, 2011, 10:14pm UTC](https://forum.kirupa.com/t/object-movement/320669/1 "2011-03-29T22:14:16Z")

</div>

i am doing a tut out of a book but im stuck.

This code below works fine. It gives an object named bal some speed when you drag it. The thing is it gives it speed when you just click it as well. I want to give is speed only when it is really dragged. This code is on a object named “bal”

```auto
on (press) {
    startDrag(this, false, _root.xpos-50, _root.ypos, _root.xpos, _root.ypos); 
}
on (release) {
        stopDrag();
        _root.v = (_root.xpos-_x)/5;
}
onClipEvent (enterFrame) {
    _root.sV = "snelheid = "+_root.v;
    xpos += _root.v *= 1.1;
    if (hitTest(_root.doel)) {
        _root.doel._visible = false;
        _root.geraakt = true;
    }
    if (_root.geraakt) {
        _root.v = 0;
    }
}

```

This is code on the main timeline:

```auto
with (bal) {
    ypos = _y;
    xpos = _x;
}
var v:Number = 0; // snelheid
var geraakt:Boolean = false; // doel geraakt?

```

This is something i tried:

```auto
on (release) {

    stopDrag();
if (_x == 0) {
    _root.v = 0;
}

else {_root.v = (_root.xpos-_x)/5;}
}

```

hope someone got any tips for me to better understand it all.
