delgado
Here's a example I made that hopefully is what you want.
What I've done there is this:
I create the background, the player and a invisible sprite that I called "camera".
"camera" has the scrollTo behaviour, so the camera is always following this sprite.
I align the camera sprite in the middle of the window, by clicking in it, "Align" -> "Window" -> "center horizontal" / "center vertical".
Then in the event sheet I see if the player passes the viewportRight or Left. If yes, I move the "camera" sprite according to the windows width size of the project. In this case it's 640, so I put 640. If you ever change the windows width in the Project Properties, change the 640 to the new value you changed. (but don't forget to align horizontal/vertically again, otherwise it will not work as expected).
I hope this is what you want and that my explanation is clear. English is not my first language.
dropbox.com/s/d62dj98kbqh2ccd/camera-example.capx
Edit:
There's an error if you go all the way to the end of the layout and then go back. The camera don't align properly... well, I don't now how to fix it. I'd try to take a look at it now, but new it's christmas and I don't have that much time. Sorry.