Animating MC's in a Game

Hello All,
I am working on animations for my game. I am having trouble understanding how to control what animations to play using AS3 (such as running, idle, etc.)

I have an MC called player and inside player I have a lot of motion tweens that make up all the animations… for example frames 1-20 is an idle animation, frames 21-40 is running, etc.

How do I play these sequences in AS3…
Would it be something like…?

running = true; frame=41; if (running){if (frame>40) player.gotoAndPlay(21); frame+=1;}