A picture illustrates how to swat a fly.
The brains of flies are wired to avoid the swatter, US researchers said on Thursday.
At the mere hint of a threat, the insects adjust their preflight stance to flee in the opposite direction, ensuring a clean getaway, they said in a finding that helps explain why flies so easily evade swipes from their human foes.
"These movements are made very rapidly, within about 200 milliseconds, but within that time the animal determines where the threat is coming from and activates an appropriate set of movements to position its legs and wings," Michael Dickinson of the California Institute of Technology said in a statement.
"This illustrates how rapidly the fly's brain can process sensory information into an appropriate motor response," said Dickinson, whose research appears in the journal Current Biology.
Dickinson's team studied this process in fruit flies using high-speed digital imaging equipment and a fancy fly swatter.
In response to a threat from the front, the fly moves its middle legs forward, leans back and raises its back legs for a backward takeoff. If the threat is from the side, the fly leans the other way before takeoff.
The findings offer new insight into the fly nervous system, and lends a few clues on how to outsmart a fly.
"It is best not to swat at the fly's starting position," Dickinson said. Instead, aim for the escape route.
Dickinson, a bioengineer, has devoted his life's work to the study of insect flight. He has built a tiny robotic fly called Robofly and a 3-D visual flight simulator called Fly-O-Vision.