Error: panning over movie clip both Horiz.&Vert

So I found this code that lets me pan over a movie clip horizontally.



import fl.transitions.Tween;
import fl.motion.easing.*;
import fl.transitions.TweenEvent;


var workspageTween:Tween


stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoved)


function mouseMoved(e:MouseEvent)
{
    var xPercent = mouseX / stage.stageWidth;


    var newXPos = (stage.stageWidth - workspage.width) * xPercent;
    workspageTween = new Tween(workspage, "x", Circular.easeOut, workspage.x, newXPos, 1, true);
}

And I wanted to incorporate the Y direction, too, so I could pan in all directions. So now it looks like this:



import fl.transitions.Tween;
import fl.motion.easing.*;
import fl.transitions.TweenEvent;


var workspageTween:Tween


stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoved)


function mouseMoved(e:MouseEvent)
{
    var xPercent = mouseX / stage.stageWidth;
    var yPercent = mouseY / stage.stageHeight;
    var newXPos = (stage.stageWidth - workspage.width) * xPercent;
    workspageTween = new Tween(workspage, "x", Circular.easeOut, workspage.x, newXPos, 1, true);
    var newYPos = (stage.stageHeight - workspage.height) * yPercent;
    workspageTween = new Tween(workspage, "y", Circular.easeOut, workspage.y, newYPos, 1, true);
}

While that does work, it’s been giving me “Error #1009: Cannot access a property or method of a null object reference. at allbuttons1920EXP_fla::MainTimeline/mouseMoved()[allbuttons1920EXP_fla.MainTimeline::frame165:24]” And is probably why I’m getting another glitch (that, at first, didn’t seem relevant to this).

Frame 165:24 refers to this line from above:

var newXPos = (stage.stageWidth - workspage.width) * xPercent;

I think it has to do with the fact that I just copypasta’d the lines with the x bits and replaced them with y.

So what is the proper way to write this code so that it incorporates both X and Y?

I have a feeling this is probably something obvious to someone who learned as3 properly from the ground up, haha…