The main reason your getting flies is because the adult flies are able to reach your food, and veggie scraps.
For anything you place in your composter, you need to bury it at least 2", don't matter with what, just needs to be covered on all sides.
You can also try hanging plastic freezer bags filled with water near the composter. :confused:
Some gardeners swear by it.
Verminators : HowStuffWorks Articles : Discovery Channel
K