Play to and stop (character movement MC)

Hello helpful flash friends. I need some help or a glass of water thrown in my face.

I have a MC which is a lady that raises her arms up and down. From the main timeline i want to tell that “ladyMC” (also sitting on the main timeline) to play to and stop on specific frames. I have tried it two different ways but am obviously missing something.

The first way i tried just using an if/else and getting the current frame #.

if(lady._currentframe < 22){
    	lady.play();
	}else if(lady._currentframe >= 22){
   		lady.stop();
}

The second way i tried setting a variable (which is being passed successfully) so that when the ladyMC hits the frame i want it to stop on, it changes the variable.

lady.play();

	
if(ladyvar==2){
   		lady.stop();
}

In both examples, the ladyMC plays through and never stops. Your help is appreciated. This seems so simple but is driving me crazy.

For your first example, make sure the actionscript is being called consistently. If its on the main stage and you only have one frame there, it is only executing the code the first time. (so, the _currentframe then would probably be like 1, so it plays…then doesnt re-evaluate _currentframe). Not sure if this is your situation.

To solve this, you would need to stick the code in a function and use setInterval or a MC with two frames where there is AS on one and not the other, with no stop(). This will call the code at half your framerate.

I think thats all right…correct me if not.

You might also try a nap.

Thanks so much for the reply. I solved it by putting the code on the MC itself and that seems to work great. I appreciate the response!