Something like this is already implemented for the pokémon icons (i.e. those you see in the party screen). They're only two frames, and they repeat themselves over and over, but it's a start.
Try mimicking this, and looking up a way to freeze the animation on a particular frame after a certain time (or just change the picture used). Alternatively, gif files can probably be used (again, you'd need to find out how to freeze the gif file at some point or change the picture used).
It's not something I've looked up, so I can't offer anything more than my ideas. It's up to you to get the know-how.