one thing that helps in debugging these issues is cleaning up your code... so lets sort this up so that it's more readable
ActionScript Code:
for(var t = 0;t<smallEnemys.length;t++)
{
var ix:Number = smallEnemys[t].mc.x;
var iy:Number = smallEnemys[t].mc.y;
var ir:Number = smallEnemys[t].mc.rotaiton;
var irad:Number = ir * Math.PI / 180;//lets also store a radians version
if(thisplayer.x < (ix+200) && thisplayer.x > (ix - 200) && thisplayer.y < (iy + 200) && thisplayer.y > (iy - 200))
{
trace("ATTACK ATTACK!!!");
} else {
var nx:Number = ix + Math.cos(irad) * 2;
var ny:Number = iy + Math.sin(irad) * -2;
smallEnemysHit[t].x = smallEnemys[t].mc.x = nx;
smallEnemysHit[t].y = smallEnemys[t].mc.y = ny;
for(var g:int=0;g<fixedObjects.length;g++)
{
if(smallEnemysHit[t].hitTestObject(fixedObjects[g].mc))
{
//smallEnemysHit[t] is redundant, was set 7 lines ago
smallEnemysHit[t].x = smallEnemys[t].mc.x = nx;
smallEnemysHit[t].y = smallEnemys[t].mc.y = ny;
//ALERT!!!!
//look here, see you don't say smallEnemys[t].mc.rotaiton...
//you say smallEnemys[t].rotation...
//smallEnemys[t].mc.rotation = smallEnemys[t].rotation + 135 + randomRange(0,90);
//that's probably your problem
//an undefined property coerced as a Number will be NaN
//so lets change it to use our already stored rotation from above
var nr:Number = ir + randomRange(135,225); //this was a random RANGE function, so make it a range
nr = wrap(nr, 360, 0);
smallEnemys[t].mc.rotation = nr;
}
}
}
}
/**
* wrap a value around a range, similar to modulus with a floating minimum
*/
function wrap(val:Number, max:Number, min:Number = 0):Number
{
val -= min;
max -= min;
if(max == 0) return min;
val %= max;
val += min;
while (val < min)
val += max;
return val;
}
ok, it's a little more readable now... and check out my comments where it say "ALERT"
that's probably your problem