This is why i hate coding!

i copied this code from a book … so you would think it would work

function createEnemy() {
	if (newWnemy == maxEnemies) {
		newEnemy = 1;
	_root.attachMovie("enemy", "enemy"+newEnemy, newEnemy);
	setProperty(eval("enemy"+newEnemy), _x, _root.stageWidth-random(_root.stageWidth));
	setProperty(eval("enemy"+newEnemy), _y, -eval("enemy"+newEnemy)._height/2));

here’s the error it gives me

Scene=Scene 1, Layer=actions, Frame=2: Line 8: ‘;’ expected
setProperty(eval(“enemy”+newEnemy), _y, -eval(“enemy”+newEnemy)._height/2));

Scene=Scene 1, Layer=actions, Frame=2: Line 9: Unexpected ‘}’ encountered

if i take the } off the end that error goes away but that doesnt make sense b/c then it leaves a bracket open

and it gives me the same error for line 8 with or without the ; at the end … but i think it should be there b/c every actionscript line i see has to have ; or { at the end

help please


Why do you have a minus here infront of this?

Another error:

if (new<b>Wnemy</b> == maxEnemies)

thx for catching the spelling error.

the - is in front of the eval in the book … i checked

that still doesnt help though with the syntax errors this movie is producing ;(

Isnt it possibly an error in the book? If its a poorly published book you can expect these kinds of things.

I have never seen that syntax.

it is possible … but when i take the - away … i still get the same errors. and thats not causing an error at the moment ;(

setProperty(eval("enemy"+newEnemy), _y, -eval("enemy"+newEnemy)._height/2));

Count the ( and the ). Compare. Correct.

pom :slight_smile:

Ding Ding Ding, I know the problem and I do it all the time, I am getting used to not doing it now though.

thanks big guy =)