Need a timer to stop my movie..how?

Hi

I have a simple 30 frame animation which plays over and over. It plays during while the audio plays. I want to stop my animation when the audio stops. I know how long is the audio (30sec) so I just want a timer to stop my animation after say 30 sec or 30 times. Its not critical.

This for your info only sop you know how my audio is played.
My audio has a keyframe which loads the sound like so -
x = new Sound();
x.loadSound(“mp3/cocky4web-music-mono.mp3”, true);

I have someting like this at the end of my animation key frame but its not working. What is missing?

counter++;
if (counter<30) {
gotoAndPlay (“start”);
}
else {
stop();
}

Thanks