When mc hits stage boundary - transfer to opposite edge

I have an mc which moves on pressing buttons. I want it to come to the left of the stage if it hits the right end. Simple, isn’t it? But I want to have one move thing done. I want only that part of the mc to come to the left which has hit the boundary.

For example, Let this be the mc-


----
|  |
|  |
----

When half of it hits the right end, only half should be transferred to the left end.


--                         --
 |                         |
 |                         |
--                         --

Please help.