How to loop animation

Hi, I’m trying to figure out a method that can do this

Jump to and play at frame 5.

play frame 5 until it reaches frame 20

When reaches frame 20, repeat back to frame 5 and do it over again.

The process is repeated while a ‘down arrow’ button is pressed. It breaks when button is released.

Can someone think of an algorithm or method? I’m very new to actionscript.