ok well I have the enemys moving and randomly spawning, but i still have my original problem even after using attachMovie. here's my code on frame 1:
stop();
onEnterFrame = function () {
for (i=1; i<((_root.stats.level*5)+1); i++){
_root.attachMovie("enemy", "MC"+i, 1000+i);
_root["MC"+i]._x = random(600)+550;
_root["MC"+i]._y = random(600)-150;
}
}
var bc=15;
var snd = new Sound();
snd.attachSound("9mm_snd");
_root.onMouseDown = function(){
_root.snd.start(0,0);
if(_root.stats.ammo<=1){
_root.stats.ammo=0;
gotoAndStop(2);
}else{
_root.stats.ammo--;
}
bc++;
if(bc>30){
bc=15;
}
duplicateMovieClip("bullet", "b"+bc, bc);
}
and heres the code on the first frame of the enemy mc that is not on the stage:
stop();
var spd = 1;
onLoad = function(){
pmove();
}
pmove = function (){
if(this.hitTest(_root.wall)){
this.play();
}
if(this.hitTest(_root.wall_3)){
this.play();
}
if(this.hitTest(_root.wall_4)){
this.play();
}
_visible = true;
Xdiff=_parent.player._x-_x;
Ydiff=_parent.player._y-_y;
radAngle=Math.atan2(Ydiff,Xdiff);
_rotation=int((radAngle*360/(2*Math.PI))+90);
if(_root._currentframe == 3){
this.removeMovieClip();
}
if(this.hitTest(_parent.player)){
//attack or something...
}else{
if(_rotation>180){
_y+=(spd*Math.cos(Math.PI/180*_rotation));
_x-=(spd*Math.sin(Math.PI/180*_rotation));
}else{
_y-=(spd*Math.cos(Math.PI/180*_rotation));
_x+=(spd*Math.sin(Math.PI/180*_rotation));
}
}
}