I have a little game I’m making for school, and one of my attachMovie lines is not working. I added a line to test if the movieClip is was attached and it returns NULL. I have tried everything in my knowledge and need help please.
This is the code to fire the bullet:
function onMouseDown() {
h++;
angle = turret._rotation-1;
bullet_x = turret._x+48*Math.cos(angle*Math.PI/180);
bullet_y = turret._y+48*Math.sin(angle*Math.PI/180);
var bulletN = "bullet"+h;
_root.attachMovie("bullet", bulletN, _root.getNextHighestDepth(), {_x:bullet_x, _y:bullet_y});
if (_root[bulletN] == NULL) {
trace("The bullet wasn't created!");
}
_root[bulletN].dirx = Math.cos(angle*Math.PI/180)*firepower;
_root[bulletN].diry = Math.sin(angle*Math.PI/180)*firepower;
_root[bulletN].onEnterFrame = function() {
this._x += 50;
this._y += 50;
};
}
My hunch is something is wrong with this line:
_root.attachMovie("bullet", bulletN, _root.getNextHighestDepth(), {_x:bullet_x, _y:bullet_y});
Any help is welcome! Thanks!