How to get an object to remember its state when returning to its frame

Let’s say you begin with a rectangle placed manually on the stage on frame 1. On the frame script you move its coordinates. Next you leave the frame to frame 2. You do something in frame 2, then return to frame 1. The rectangle is now back at its original coordinates and forgets where it had been moved in code. Is there anyway to get the rectangle to return to its last prior state without a lot of hacking to explcitly store and restore the location? Thanks.

Not sure why I can’t edit text here after I’ve written it, but just to clarify, the frame script that moves the rectangle in frame 1 is assumed to only be operative the first time through, or it could be something like rect_mc.x += 10, so its location should always be increasing each time control returns to frame 1.