# Sticky buttons problem

**URL:** <https://forum.kirupa.com/t/sticky-buttons-problem/238942>\
**Category:** Uncategorized\
**Created:** [September 17, 2007, 11:48am UTC](https://forum.kirupa.com/t/sticky-buttons-problem/238942 "2007-09-17T11:48:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unnamed](https://avatars.discourse-cdn.com/v4/letter/u/91b2a8/32.png) [@unnamed](https://forum.kirupa.com/u/unnamed)\
**Post date:** [September 17, 2007, 11:48am UTC](https://forum.kirupa.com/t/sticky-buttons-problem/238942/1 "2007-09-17T11:48:36Z")

</div>

Hi,

Could you guys help me with this code:

```auto

MovieClip.prototype.sticky = function() {
    this.lockX = this._x; 
    this.lockY = this._y;
    this.spX = 0;
    this.spY = 0;
    this.onEnterFrame = function() {
        if (this.hitTest(_root._xmouse, _root._ymouse)) {
            this.newX = this.lockX + (_root._xmouse - this.lockX) * 0.65;
            this.newY = this.lockY + (_root._ymouse - this.lockY) * 0.65;
        } else {
            this.newX = this.lockX;
            this.newY = this.lockY;
        }
        this.spX += this.newX - this._x;
        this.spY += this.newY - this._y;
        this.spX *= 0.7;
        this.spY *= 0.7;
        this._x += this.spX;
        this._y += this.spY;
    };
};

menuholder.btn_booking.sticky();
menuholder.btn_galeria.sticky();
menuholder.btn_menu.sticky();
menuholder.btn_onas.sticky();
menuholder.btn_recenzje.sticky();

```

its protoype for sticky buttons, why it wont work for me ? when i rollower on my button it bounces like stupid, from one end of stage to another… is it becouse i have them in container ? (menuholder) ?

pls help 🙂
