connecting via hdmi to tv and optical out to receiver will likely work, except you most likely will not get surround. On most tvs, the optical audio out will only give 5.1 surround for over the air programming it receives. Other sources will be stereo only.
The best way to set it up is to go hdmi to receiver, then hdmi from receiver to tv. Of course, this assumes an hdmi-capable receiver. If the receiver only has optical (or coax) inputs for audio, then run hdmi to tv and optical from appletv to receiver.