When I was in veterinary school, I learned that as long as a dog has normal eyesight, fly biting behavior (snapping at the air as if trying to catch a nonexistent fly) is usually a symptom of a partial seizure.
A partial seizure is caused by abnormal electrical activity within a relatively small portion of the brain.