# AS3 Parallax Gallery

**URL:** <https://forum.kirupa.com/t/as3-parallax-gallery/288504>\
**Category:** flash\
**Created:** [May 17, 2009, 4:59am UTC](https://forum.kirupa.com/t/as3-parallax-gallery/288504 "2009-05-17T04:59:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnthonyV1121](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@AnthonyV1121](https://forum.kirupa.com/u/AnthonyV1121)\
**Post date:** [May 17, 2009, 4:59am UTC](https://forum.kirupa.com/t/as3-parallax-gallery/288504/1 "2009-05-17T04:59:45Z")

</div>

Can anyone translate this AS2 code to AS3? I tried myself but I am having a problem with the setProperty method. Code is pasted and here’s the link to the source files. Thanks, any help greatly appreciated.

[http://www.webdesignerwall.com/tutorials/parallax-gallery/all-comments/#comments](http://www.webdesignerwall.com/tutorials/parallax-gallery/all-comments/#comments)

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