Visit the notions of Heraldry (or at least British Heraldric practice). There are two groups of colours -- the Tinctures (red, green, blue, black, and purple) and the Metals (gold/yellow and silver/white). Adjacent fields have to belong to opposing groups. A flag consisting of three stripes could be colored red/white/red or red/yellow/blue, but not red/black/white. This method gives the best contrast between fields on a flag or a shield.
Throw in some additional "neutral" combinations like checky (chequer board pattern of a tincture and a metal), and a few simple figures (vertical stripe, horizontal stripe, left and right diagonal stripes and a chevron), and you are set.