OK, I’ve followed the tutorial [kirupa.com - Interactive Image Panning, Page 1], and I’ve kinda got the x-pan working, but it does overshoot the image for some reason.
I even managed to get the y-pan to work too, but it still overshoots.
Here’s my adaption of the code:
this.onMouseMove = function()
{
constrainedMove(bg_mc, 4, 1, 4, 1);
};
function constrainedMove(target:MovieClip, xspeed:Number, yspeed:Number) {
var mousePercent_x:Number = ((_xmouse/Stage.width));
var mousePercent_y:Number = ((_ymouse/Stage.height));
var mSpeed_x:Number = 1-mousePercent_x;
var mSpeed_y:Number = 1-mousePercent_y;
target.destX = Math.round(-((target._width-Stage.width)*mSpeed_x));
target.destY = Math.round(-((target._height-Stage.height)*mSpeed_y));
target.onEnterFrame = function() {
if (target._x == target.destX)
{
delete target.onEnterFrame;
}
else
{
target._x += Math.ceil((target.destX-target._x)(xspeed/100));
}
if (target._y == target.destY)
{
delete target.onEnterFrame;
}
else
{
target._y += Math.ceil((target.destY-target._y)(xspeed/100));
}
};
}
Otherwise, it’s set up as in the tutorial.
See http://img214.imageshack.us/my.php?image=pan1sd6.swf for the result.