Hi everyone
As a beginner I having a lot of difficulties upgrade my website fom AS2 to AS3.
I use to use a amazing piece of code that I found in this website in order to scroll the background using the mouse. It was perfect but have to upgrade…
stop();
this.onMouseMove = function() {
constrainedMove(BigMC_mc, 30, -1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
var mSpeed:Number;
var mousePercentX:Number = _xmouse/Stage.width;
if (dir == 1) {
mSpeed = 1-mousePercent;
} else {
mSpeed = mousePercent;
}
target.destY = Math.round(-((target._height-Stage.height)*mSpeed));
target.onEnterFrame = function() {
if (target._y == target.destY) {
delete target.onEnterFrame;
} else if (target._y>target.destY) {
target._y -= Math.ceil((target._y-target.destY)*(speed/100));
} else if (target._y<target.destY) {
target._y += Math.ceil((target.destY-target._y)*(speed/100));
}
if ((target._y+target._height)<Stage.height) {
target._y=Stage.height-target._height
}
if ((target._y)>0) {
target._y=0
}
ç
I really don’t get AS3 and wonder if anyone here has already translated this code. If yes It would be very helpful for me. If not, where can I find a code which has the same function or similar but in AS3 ?
Thanx a lot !