Flies are attracted to lamps because of light, heat, and the potential presence of other insects they may feed on. They may also be drawn to reflective surfaces. To keep flies away, turn off lights when not in use, use lampshades, keep food covered, and place fly traps near lamps.