By Matt McGrath
BBC World Service science reporter
High-resolution video of a fly avoiding a swatter - Courtesy of the California Institute of Technology
Researchers in the US say that they have solved the mystery of why flies are so hard to swat.
They think the fly's ability to dodge being hit is due to its fast acting brain and an ability to plan ahead.
High speed, high resolution video recordings revealed the insects quickly work out where a threat is coming from and prepare an escape route.
The research suggests that the best way of swatting a fly is to creep up slowly and aim ahead of its location.
The study has been published in the journal Current Biology.
Most people will have experienced the curiously frustrating sensation of carefully attempting to swat a fly, only to swing and miss while the intrepid insect buzzes off to safety.
Over the years there have been different theories put forward to explain the fly's uncanny ability to outwit our whacking endeavours.
when the fly makes planning movements prior to take-off, it takes into account its body position at the time it first sees the threat
Michael Dickinson, Caltech
But scientists at the California Institute of Technology (Caltech) say it is down to quick-fire intelligence and good planning.
They filmed a series of experiments with fruit flies and a looming swatter.
The researchers discovered that long before the fly leaps it calculates the location of the threat and comes up with an escape plan.
Flies put their bodies into pre-flight mode very rapidly - Within 100 milliseconds of spotting the swatter they can position their centre of mass in the right way so that a simple extension of their legs propels them away from any threat.
The scientists found that flies were able to put themselves into this rapid reaction position no matter whether they were grooming, feeding or simply walking.
According to Caltech's Professor Michael Dickinson this illustrates the speed and complexity of the fly's brain.
"We've found that when the fly makes planning movements prior to take-off, it takes into account its body position at the time it first sees the threat," he explained.
"Our experiments showed that the fly somehow 'knows' whether it needs to make large or small postural changes.
"This means the fly must integrate visual information from its eyes which tell it where the threat is approaching from, with mechano-sensory information from its legs, which tells it how to move to reach the proper pre-flight pose."
So can this data make us more efficient swatters? Possibly. It is best to creep up on a fly with stealth, as they are unable to register slow movements.
When it comes to striking the blow, Professor Dickinson said it was a good idea not to aim at the fly's starting position.
"It's best to aim a bit forward of its location and try and anticipate where the fly will jump when it first sees your swatter," he explained.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.