It's similar, but that solution was only for parallax
I need it to take into account the layers Scale and Rotation also
Something that was linked to caught my eye though..
The bottom of this manual entry:
Convert from canvas coordinates to layer coordinates. Useful for converting e.g. mouse co-ordinates to layer co-ordinates. See Mouse for an example.
Sounds like it could be the thing that is used for the mouse.x("layer") expression.. Which would be exactly what I need. I just have no idea how to implement this.