Hi,
I have this nicely working file with parallax effect horizontal scrolling. The code comes from this tutorial: 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);
}