class EnemyShip extends MovieClip
{
var speed;
var shootTimer;
function onLoad()
{
_x = 700
_y = Math.random()*250 + 50;
speed = Math.random()*5 + 5;
shootTimer = 0;
}
function onEnterFrame()
{
_x -= speed;
if(_x < -100)
{
this.removeMovieClip();
}
if(this.hitTest(_root.ship))
{
explode();
}
shootTimer +=1;
if(shootTimer > 30)
{
shootTimer = 0
var missile = _root.attachMovie("EnemyMissile","EnemyMissile" + _root.getNextHighestDepth(). _root.getNextHighestDepth());
missile._x = _x -50
missile._y = _y + 2
}
}
function explode()
{
var explosion = _root.attachMovie("Explosion","Explosion" + _root.getNextHighestDepth()._root.getNextHighestDepth());
explosion._x = _x;
explosion._y = _y;
this.removeMovieClip();
}I get a syntax error saying "There is no method with the name '_root'.
Last edited by juststickman (2010-04-06 16:00:39)
Offline
Also the ship keeps ending up in the top left corner.... Does this have something to do with
var missile = _root.attachMovie("EnemyMissile","EnemyMissile" + _root.getNextHighestDepth(). _root.getNextHighestDepth());
missile._x = _x -50
missile._y = _y + 2?
Sorry about double post, the forum wouldn't let me post both parts in one post.
Last edited by juststickman (2010-04-06 16:01:18)
Offline
I don't know how whatever programming language you're using works
(I'm guessing actionscript because of the term "movies", and you've been talking about it)
You could temporarily remove the one part and see if that fixes it.
Offline
BWOG wrote:
I don't know how whatever programming language you're using works
(I'm guessing actionscript because of the term "movies", and you've been talking about it)
You could temporarily remove the one part and see if that fixes it.
I know that the error is those parts because the syntax error says it's on those lines...
Yeah, it's actionscript.
Offline
Is anybody there?
I need a better place to post these problems...
Offline
Don't post AS code here, most people here won't even recognize the syntax.
Use the newgrounds flash forum //best for fast replies
the kirupa forums
or the flashkit forums
As for your problem, try getting rid of the var "name" = _root.blah...
You only need the _root.blah... part
Also remember to set the linkage if you use the attachmovie command.
Offline