I suppose one way would be to use these system expressions.
CanvasToLayerX(layer, x, y)
CanvasToLayerY(layer, x, y)
LayerToCanvasX(layer, x, y)
LayerToCanvasY(layer, x, y)
Cx = LayerToCanvasX(sprite.layer, sprite.x, sprite.y)
Cy = ...
Lx = CanvasToLayerX(sprite2.layer, cx, cy)
Ly = ...
D = distance(sprite2.x,sprite2.y, lx,ly)
Another is to come up with the formula to do the parallax. It may end up being simpler but may take a bit of fiddling to get it right.
Off the top of my head if there’s no rotation then
X2 = ((x-scrollx)*parallax+scrollx)*scale
Could be a possible start