Transient visual loss affecting both eyes, usually accompanied by flashes, lights or zig-zag lines is usually due to migraine.
Where only one eye is affected it is normally due to transient interruption of the blood supply to the retina (amaurosis fugax) or optic nerve (ischaemic optic neuropathy).