ActionScript makes it easy to count things. You can use a variable to count the number of times you pass through a frame.
For instance, to playback frames 10 through 20 five times, then the following Flash 4 ActionScript placed on frame 20 will accomplish that:

