…when it lines up with the mouse. Any ideas why? http://www.gregrochford.co.uk/kirupa/bar.swf
http://www.gregrochford.co.uk/kirupa/bar.fla
onMouseMove = function () {
constrainedMove(bg_mc, 4, 0, _xmouse);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
var mousePercent:Number = _xmouse/Stage.width;
var mSpeed:Number;
if (dir == 1) {
mSpeed = 1-mousePercent;
} else {
mSpeed = mousePercent;
}
target.destX = Math.round(-((target._width-Stage.width)*mSpeed));
target.onEnterFrame = function() {
if (target._x == target.destX) {
target.onEnterFrame = null;
} else if ((target.destX-target._x)>0) {
target._x += Math.ceil((target.destX-target._x)*(speed/100));
} else {
target._x += Math.floor((target.destX-target._x)*(speed/100));
}
};
}
function definedMove(target:MovieClip, speed:Number, destination:Number) {
target.onEnterFrame = function() {
if (target._x == destination) {
target.onEnterFrame = null;
} else if ((destination-target._x)>0) {
target._x += Math.ceil((destination-target._x)*(speed/100));
} else {
target._x += Math.floor((destination-target._x)*(speed/100));
}
};
}