do
action$=ai get entity action$
here's some of my code for controlling animation. It's pretty similar to what you've got, but it works.. Hope this helps.
it's called as a function from the main loop, because I first need to check if the entity is dead or not.
function marineanimations(i)
if AI Get Entity Action$ (i)="stopped" then loop object i,74,75 : hide object i+1100
if AI Get Entity Action$ (i)="Moving Forwards" then loop object i,55,72 : hide object i+1100
if AI Get Entity Action$ (i)="Strafing Left" then loop object i,35,54 : hide object i+1100
if AI Get Entity Action$ (i)="Strafing Right" then loop object i,15,34 : hide object i+1100
if AI Get Entity Action$ (i)="Stopped And Attacking" then loop object i,74,75 : shooting(i)
if AI Get Entity Action$ (i)="Moving Forwards And Attacking" then loop object i,55,72 : shooting(i)
if AI Get Entity Action$ (i)="Moving Backwards And Attacking" then loop object i,55,72 : shooting(i)
if AI Get Entity Action$ (i)="Strafing Left And Attacking" then loop object i,55,72 : shooting(i)
if AI Get Entity Action$ (i)="Strafing Right And Attacking" then loop object i,55,72 : shooting(i)
endif
endfunction