The electrons are moving around the nucleus in circular orbits. When an electron absorbed extra energy from an outside source (flame), the electron moves to a higher orbit. Colored light is emitted when the electron falls back to a lower orbit. This light is the difference between the energies of the two orbits involved.
pera maganda si chic so si dogie parang duck pero medyo bahay sila