Look at the bottom of the example gun script provided by Azerath
It says something like
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);
}The number after %obj.playThread (2 in this case) is what sequence the animation is being played in. If you want it to play when you fire, leave the number as 2. The next argument after %obj.playThread is which animation to play. You have to name your animations in the torque exporter. Then, swap out 'shiftaway' with your animation.
If you want to have the animation cycle while you are shooting, you will have to change some of the state-system.
But don't get into cycling yet, just try that first to see if it works.