# Problem with parallax scrolling

**URL:** <https://forum.kirupa.com/t/problem-with-parallax-scrolling/273192>\
**Category:** flash\
**Created:** [October 12, 2008, 9:18pm UTC](https://forum.kirupa.com/t/problem-with-parallax-scrolling/273192 "2008-10-12T21:18:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DLS](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@DLS](https://forum.kirupa.com/u/DLS)\
**Post date:** [October 12, 2008, 9:18pm UTC](https://forum.kirupa.com/t/problem-with-parallax-scrolling/273192/1 "2008-10-12T21:18:54Z")

</div>

For some reason my parallax effect doesn’t work properly the front mc doesnt scroll quit right, you can see what i mean in the example i uploaded…

[http://www.darrenleighton.co.uk/vp.html](http://www.darrenleighton.co.uk/vp.html)

I basically have a back mc and a front mc both the same size. Anyone got any ideas what iv done wrong?

heres my code:

```auto

stageWidth = Stage.width;
speed1 = 14;
speed2 = 16;
mc1Width = front_mc._width;
mc2Width = back_mc._width;
mc1X = front_mc._x;
mc2X = back_mc._x;
lock_scroll = false;
_root.onEnterFrame = function() {
    if (!lock_scroll) {
        scroll_mc();
    }
};
function scroll_mc() {
    var xdist = _xmouse-(stageWidth/2);
    mc1X += -xdist/speed1;
    mc2X += -xdist/speed2;
    if (mc1X>=0) {
        mc1X = 0;
    }
    if (mc1X<=stageWidth-mc1Width) {
        mc1X = stageWidth-mc1Width;
    }
    if (mc2X>=0) {
        mc2X = 0;
    }
    if (mc2X<=stageWidth-mc2Width) {
        mc2X = stageWidth-mc2Width;
    }
    setProperty("front_mc", _x, mc1X);
    setProperty("back_mc", _x, mc2X);
}
//create an empty mc container for content to display
createEmptyMovieClip("content_box", 200);
content_box._x = 195;
content_box._y = 92;

```
