Mouse detection image gallery


im trying to recreate an image gallery as shown here:

basicaly when your mouse moves the image adjusts based on the ratio of the viewing area.

the setup is basicaly a viewing area mc i have called (mMask) and a picture, mc that lays behind it called pichold. these two mc’s are nested within a movie clip called viewgall. im working on this on the side to then bring into another .fla when finished. these heres what i have so far for the code:

function init():Void {
//pic = attachMovie(“pichold”, “pichold”, 0);
picrangeX = (pichold._width-mMask._width)/2;
picrangeY = (pichold._height-mMask._height)/2;
centerX = mMask._width/2;
centerY = int(mMask._height/2);
pichold._x = centerX;
pichold._y = centerY;
function onEnterFrame():Void {
var dx:Number = _xmouse-centerX;
var dy:Number = _ymouse-centerY;
var angle:Number = Math.atan2(-dy, -dx);
var speed:Number = (Math.sqrt(dxdx+dydy))*.05;
var vx:Number = Math.cos(angle)*speed;
var vy:Number = Math.sin(angle)*speed;
if (pichold._x>=(centerX+picrangeX)) {
pichold._x = centerX+picrangeX;
if (pichold._x<=(centerX-picrangeX)) {
pichold._x = centerX-picrangeX;
if (pichold._y>=(centerY+picrangeY)) {
pichold._y = centerY+picrangeY;
if (pichold._y<=(centerY-picrangeY)) {
pichold._y = centerY-picrangeY;
pichold._x += vx;
pichold._y += vy;

im wondering if i have to take into account the stages width and height at all to get this to work properly. the x and y coors for the picture are all screwed up and i dont know why?!?

im still learning the ropes here…can anyone take a look at this and help me out?