I really need to reference the author of this parallax code but annoyingly Ive lost the forum post and Ive looked and searched for hours but I cannot find it.
Here is the code
Code:
stop();
var paused = false;
var active;
msgBox._visible = false;
var btnList = new Array();
function toggleEnabled() {
for (i in btnList) {
btnList[i].enabled = !btnList[i].enabled;
}
}
myPress = function (mc, num) {
btnList.push(mc);
mc.num = num
mc.onPress = function() {
if (!paused) {
paused = true;
this.gotoAndStop("dn");
active = this;
toggleEnabled();
msgBox._visible = true;
msgBox.play();
msgBox.msgs.gotoAndStop(active.num)
msgBox.btnClose.onPress = function() {
msgBox.play();
paused = false;
active.gotoAndPlay("up");
toggleEnabled();
msgBox._visible = false;
};
}
};
};
//
moveIt = function (wc) {
wc.imageStartX = 0;
wc.imageEndX = -wc._width + Stage.width;
wc.StartMouseX = 0;
wc.EndMouseX = Stage.width;
wc.MouseRangeX = wc.EndMouseX - wc.StartMouseX;
wc.PanRangeX = wc.imageEndX - wc.imageStartX;
//
wc.imageStartY = 0;
wc.imageEndY = -wc._height + Stage.height;
wc.StartMouseY = 0;
wc.EndMouseY = Stage.height;
wc.MouseRangeY = wc.EndMouseY - wc.StartMouseY;
wc.PanRangeY = wc.imageEndY - wc.imageStartY;
//
wc.onEnterFrame = function() {
if (!paused) {
wc.rX = (_root._xmouse - wc.StartMouseX) / wc.MouseRangeX;
wc.rX = Math.max(0, Math.min(1, wc.rX));
wc._x += ((wc.rX * wc.PanRangeX + wc.imageStartX) - wc._x) / 9;
//
wc.rY = (_root._ymouse - wc.StartMouseY) / wc.MouseRangeY;
wc.rY = Math.max(0, Math.min(1, wc.rY));
wc._y += ((wc.rY * wc.PanRangeY + wc.imageStartY) - wc._y) / 9;
}
};
};
//Call the function for each MC that is going to move. Be sure that the
//registration point of each MC is set to the upper left corner.
moveIt(bg);
moveIt(mid);
moveIt(fg);
//Set for each button that will be used, first parameter is button MC.
//Second parameter is the frame number of the msgs MC to display.
myPress(mid.btn1, 1);
myPress(fg.btn1, 2);
myPress(fg.btn2, 3);
The file was called just parallax I think. It has an image of a field and some message boxes etc. I havent used it in the same way, but I hope someone can claim ownership!
see attached file! If anyone knows the author or has the post, please inform me!