Within the range of insects, moths and butterflies and moths use sunlight for orientation, feeding and even for egg laying. Given the nature of these insects, especially moths, the absence of light at night makes them relax or even hide, so when we light in the dark a strong light, believe it day and go to the heat source, even when fire coming to die. The insects are especially attracted by the ultraviolet light emitted at 365 nanometers, the best length for claiming wave insects, because they have a radioactive cells that attract them to the light energy. The white light attracts these insects, but the yellow light does not.
The flying insects are attracted to light.
In the study of biology it is called compound eyes, the visual organ with some insects, including flies, consist of hundreds of units called ommatidos receptive, sensory cells individually distinguish between light and darkness and some kind of color, begins in the ultraviolet range and reaches the orange. The image perceived flies are the set of multiple ommatidos oriented in different directions. The compound eye is capable of detecting fast movements and elementary principles of vision.
Flies and many other insects are attracted to light, especially at night, they are immersed in the dark and the contrast between this and light, joined the cast of the insects are prepared to respond to flashy things makes the attraction is much higher.
The electrical exterminators use the attraction, with flies into the light to eliminate them.
Flies carry pigments that respond to light I inactivándose called cryptochrome, is a photoreceptor molecule which regulates the circadian rhythm of the fly, which regulates waking, rest and activity, body temperature, cardiac output and other functions more. When animals are exposed to the constant and intense light, circadian rhythm becomes arrhythmic, confusing night and day, disorienting the internal biological clock. To this insect it is called photopositive and to the phenomenon that reacts to light phototaxis.
Flies like all insects are cold-blooded, use light to warm.
Science does not have a concrete answer to this, but to studies, it is believed an important reason is to warm up, because they are cold-blooded animals and require heat to live. Most photopositive insects that are attracted to light tend to be nocturnal species.
Related link: http://extertronic.com/shop/gb/14-exterminators