When your horizontal movement is not 0, if sprite_index is spr_dragon_idle (or whatever), change it to spr_dragon_idle_to_run. Else, if horizontal movement is 0, if sprite_index is spr_dragon_run, change it to spr_dragon_run_to_idle. In the Animation End event, if sprite_index is spr_dragon_idle_to_run, if horizontal movement is not 0, change sprite_index to spr_dragon_run, else if horizontal movement is 0, change sprite_index to spr_dragon_run_to_idle. Else, if sprite_index is spr_dragon_run_to_idle, check if horizontal movement is 0; if it is, change sprite_index to spr_dragon_idle, else if horizontal movement is not 0, change sprite_index to spr_dragon_idle_to_run.
Do not allow changing directions unless sprite_index is spr_dragon_idle, otherwise you'll have some weird visual effects.
Just be wary this kind of movement can be really nice looking, but your player may feel like controls are laggy.