This may not be what you're looking for, but it's a start possibly.
This is a smooth animation.. if you want it to look like stop-animation (like South Park) I'm not sure how to do it offhand, especially since it'd have to be tweaked to get the feel "right"
But the idea above is:
A is the distance from the left hand side, and B is the distance traveled. It will move -160 to 160, making it go from 0 to
320(the limits on the editor).
sin is what makes it go left and right repeatedly.
dwfss is smooth seconds - meaning that it continuously moves, not just when the second changes
Again, sin makes the movement repeat at a constant rate, in this case dwfss which again, is smooth animation
15 is how much it rotates each second
Which will look something like this: