# Drag button snap back

**URL:** https://forum.kirupa.com/t/drag-button-snap-back/108232
**Category:** Uncategorized
**Created:** [April 22, 2004, 9:57pm UTC](https://forum.kirupa.com/t/drag-button-snap-back/108232 "2004-04-22T21:57:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Adam1](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Adam1](https://forum.kirupa.com/u/Adam1)
#### Post date: [April 22, 2004, 9:57pm UTC](https://forum.kirupa.com/t/drag-button-snap-back/108232/1 "2004-04-22T21:57:20Z")

</div>

I have a button inside a MC, and I’m trying to get it so if you pull it out a certain distance, it eases a menu out, but if it’s not out far enough it eases back in, the same, but in reverse when trying to close the menu…the code I have seems to work, but it opens when you click it first, without dragging it past the point where it has to be to fully open…hope that’s not too confusing 😉 the code it this:

```auto

_root.dragMenu.dragBut.onPress = function() {
startDrag(this._parent, false, 645, 370, 720, 370);
};
_root.dragMenu.dragBut.onRelease = function() {
trace(this._parent._x);
noBut();//disables the button while in motion
if (_global.opening == 1) {
_global.opening = 0;
} else {
_global.opening = 1;
}
if (this._parent._x>=655 && _global.opening == 1) {
this._parent.easeX(720);
} else {
this._parent.easeX(645);
}
if (this._parent._x<=715 && _global.opening != 1) {
this._parent.easeX(645);
} else {
this._parent.easeX(720);
}
stopDrag();
};

```

it drags from 645 to 720 in total…not a lot of room to play with either

if anyone has any ideas, I’d be very appreciative…thanks 😃

\*\*and a very big thanks to Voets, for his golden formula 😉

Adam
