Mixed metal thin films containing magnesium and a first-row transition element exhibit very large changes in both reflectance and transmittance on exposure to hydrogen gas. Changes in electronic structure and coordination of the magnesium and transition metal atoms during hydrogen absorption were studied using dynamic in situ transmission mode X-ray absorption spectroscopy. Mg K-edge and Ni, Co, and Ti L-edge spectra reflect both reversible and irreversible changes in the metal environments. A significant shift in the nickel L absorption edge shows it to be an active participant in hydride formation. The effect on cobalt and titanium is much less dramatic, suggesting that these metals act primarily as catalysts for formation of magnesium hydride.