I was wondering if Charizard X (when it mega evolves) loses the ability to dodge Earthquake since it is no longer a flying type and doesn't have an ability to dodge it.
Yes. Mega Charizard X loses its Flying typing and does not have Levitate, so it can be hit by Earthquake. Just because it hovers does not mean it can't be hit. See: Magnezone, Chandelure.
Source: Experience