# Parallax scrolling - turning horizontal into vertical

**URL:** <https://forum.kirupa.com/t/parallax-scrolling-turning-horizontal-into-vertical/331924>\
**Category:** flash\
**Created:** [November 28, 2013, 1:11am UTC](https://forum.kirupa.com/t/parallax-scrolling-turning-horizontal-into-vertical/331924 "2013-11-28T01:11:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GosiaP](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@GosiaP](https://forum.kirupa.com/u/GosiaP)\
**Post date:** [November 28, 2013, 1:11am UTC](https://forum.kirupa.com/t/parallax-scrolling-turning-horizontal-into-vertical/331924/1 "2013-11-28T01:11:25Z")

</div>

Hi,

I have this nicely working file with parallax effect horizontal scrolling. The code comes from this tutorial: [http://webdesignerwall.com/tutorials/parallax-gallery](http://webdesignerwall.com/tutorials/parallax-gallery)  
Now I need to make another project with the same effect, just vertical. I tried changing it myself (I changed everything in ActionScript that referred to “x” into “y” and “width” into “hight”) but it doesn’t work.

Here’s the horizontal code, working:

stageWidth = Stage.width;  
speed1 = 31;  
speed2 = 39;  
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);  
}

And here’s what I tried for the vertical effect, which didn’t work:  
stageHight = Stage.Hight;  
speed1 = 31;  
speed2 = 39;  
mc1Hight = front\_mc.\_Hight;  
mc2Hight = back\_mc.\_Hight;  
mc1Y = front\_mc.\_y;  
mc2Y = back\_mc.\_y;

lock\_scroll = false;  
\_root.onEnterFrame = function () {  
if (!lock\_scroll)  
scroll\_mc();  
}

function scroll\_mc() {  
var ydist = \_ymouse-(stageHight/2);  
mc1Y += -ydist/speed1;  
mc2Y += -ydist/speed2;  
if (mc1Y\>=0) {  
mc1Y = 0;  
}  
if (mc1Y\<=stageHight-mc1Hight) {  
mc1Y = stageHight-mc1Hight;  
}  
if (mc2Y\>=0) {  
mc2Y = 0;  
}  
if (mc2Y\<=stageHight-mc2Hight) {  
mc2Y = stageHight-mc2Hight;  
}  
setProperty(“front\_mc”, \_y, mc1Y);  
setProperty(“back\_mc”, \_y, mc2Y);  
}
