I second what Lancecham said. Put some slices of fruit and the fruit flies will stay close. Also if you have them in a cup you can coat the top part of the cup and brim with a vegetable oil. The surface is too slick for the FF to climb up and out.
Ive also read (but have not tried) that if you dust the inside walls of the cup and smooth it around with your fingers, they have a hard time climbing that as well.