# Interactive Background wobbles

**URL:** <https://forum.kirupa.com/t/interactive-background-wobbles/218405>\
**Category:** Uncategorized\
**Created:** [March 7, 2007, 2:46pm UTC](https://forum.kirupa.com/t/interactive-background-wobbles/218405 "2007-03-07T14:46:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![g\_rochford](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@g\_rochford](https://forum.kirupa.com/u/g_rochford)\
**Post date:** [March 7, 2007, 2:46pm UTC](https://forum.kirupa.com/t/interactive-background-wobbles/218405/1 "2007-03-07T14:46:14Z")

</div>

…when it lines up with the mouse. Any ideas why? [http://www.gregrochford.co.uk/kirupa/bar.swf](http://www.gregrochford.co.uk/kirupa/bar.swf)  
[http://www.gregrochford.co.uk/kirupa/bar.fla](http://www.gregrochford.co.uk/kirupa/bar.fla)

```auto
onMouseMove = function () {
    constrainedMove(bg_mc, 4, 0, _xmouse);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
    var mousePercent:Number = _xmouse/Stage.width;
    var mSpeed:Number;
    if (dir == 1) {
        mSpeed = 1-mousePercent;
    } else {
        mSpeed = mousePercent;
    }
    target.destX = Math.round(-((target._width-Stage.width)*mSpeed));
    target.onEnterFrame = function() {
        if (target._x == target.destX) {
            target.onEnterFrame = null;
        } else if ((target.destX-target._x)>0) {
            target._x += Math.ceil((target.destX-target._x)*(speed/100));
        } else {
            target._x += Math.floor((target.destX-target._x)*(speed/100));
        }
    };
}
function definedMove(target:MovieClip, speed:Number, destination:Number) {
    target.onEnterFrame = function() {
        if (target._x == destination) {
            target.onEnterFrame = null;
        } else if ((destination-target._x)>0) {
            target._x += Math.ceil((destination-target._x)*(speed/100));
        } else {
            target._x += Math.floor((destination-target._x)*(speed/100));
        }
    };
}

```
