# gotoAndStop() functionality

**URL:** <https://forum.kirupa.com/t/gotoandstop-functionality/269802>\
**Category:** flash\
**Created:** [September 1, 2008, 9:48pm UTC](https://forum.kirupa.com/t/gotoandstop-functionality/269802 "2008-09-01T21:48:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylverwolf79](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@Sylverwolf79](https://forum.kirupa.com/u/Sylverwolf79)\
**Post date:** [September 1, 2008, 9:48pm UTC](https://forum.kirupa.com/t/gotoandstop-functionality/269802/1 "2008-09-01T21:48:58Z")

</div>

Greetings all,

I am attempting to build an rpg combat engine, and all seems to be going well, except one thing - my animations are not playing correctly.

In the player\_mc, I have 4 frames, each containing a movie clip animation, and the stop(); actionscript, as follows:  
Frame 1: playerIdle\_mc  
Frame 2: playerAttack\_mc  
Frame 3: playerMagic\_mc  
Frame 4: playerDead\_mc

I have an enemy\_mc that is set up exactly the same, excepting that player is replaced with enemy.

Here is a small sample of the code, that I think should be relevant and specific enough to explain the problem:

if (pAtt == true) { //If player is attacking  
[INDENT]player\_mc.gotoAndStop(2); //display the attack animation  
eHP -= 1; //damage the enemy  
pAtt = false; //the attack is over  
pTurn = false; //the turn is over  
if (eHP \<= 0) { //if enemy hp 0 then he’s dead  
[INDENT]eIsDead = true;  
[/INDENT]} else { //otherwise it’s his turn  
[INDENT]eTurn = true;  
[/INDENT]}  
player\_mc.gotoAndStop(1); //display player’s idle animation  
[/INDENT]}

Now, prior to attacking, the player\_mc was displaying the idle animation, and through this attack routine, it continues doing so - it snaps to the default position I have set up so the animations blend, but then continues to display the idle animation. I think it may actually be going there and trying to display it, but something is missing and it goes backl to idle, which i tell it to do at the end of the attack.

I am pretty certain the problem lies in the code “player\_mc.gotoAndStop(2);”

I think somehow I’m supposed to detect how many frames the animation is and make the game pause while it plays the animation, but I’m not certain if that’s correct, or if it is, how to do it.

Any advice on this would be greatly appreciated.

Thank you in advance

-J-
