Hi,

I want to emulate a random attack. I have been trying to do this by using an animation in a movie clip which begins invisible. I generate a random number and if the number 1 is generated the movie clip is made visible and the animation plays before going invisible again. For some reason the animation doest play correctly but i am not sure how to fix it. I think its something to do with the loop.

The animation has a stop(); on the last frame and the instance of the movie clip is called attack1_mc

Any help would be awesome.



Frame 1 code:

Code:
if (attack1==3) { 
}
if (attack1==1){
}
else { 
   attack1 = 0; 
   attack1_mc._visible = false; 
} 

//attack1 
if (attack1 == 1) { 
   attack1_mc._visible = true; 
   attack1_mc.gotoAndPlay(1) 
} 
if (attack1 == 3) { 
   attack1_mc._visible = true; 
   attack1_mc.gotoAndPlay(1) 
 _global.life = _global.life-1;

}
Frame2:

Code:
num2 = random(20) 

//'to hit' check 
if (num2==1) { 
   attack1 = 3 
} 
if (num2 ==2) { 
   attack1 = 1 
}