Each corresponding flame colour is due to the excited electrons falling back to their ground state and releasing a form of energy - namely visible light. Now, according to many websites the higher the energy gap (which increases down Group 2) the higher the frequency of visible light. For e.g starting with Calcium and ending with Barium - the flame colours truly do increase in colour frequency - with Brick-red, Crimson, and Apple-green colours respectively.
What I don't understand - if the energy gaps increase down the Group and therefore the frequency of energy along the EM spectrum increases too, why do Magnesium and Berylium (which should have the lowest energy gaps) have the highest frequencies along the EM spectrum - i.e. emitting UV light?