Jump to content

AS3 Error 1083: Syntax error: else is unexpected NEED HELP


astro geek

Recommended Posts

I am having trouble with my code, the code is:

 

{

var num1:Number = 0.5;

if(num < num1)

mc_enemy.y += 20

num = Math.random()

else mc_enemy.y -= 20

num = Math.random()

}

 

And it shows the error, "Error 1083: Syntax error: else is unexpected", Does anybody have any suggestions?

Link to comment
Share on other sites

  I'd say my programming skills sucks, don't listen to me, but just to say that you can maybe take a look at the if else statement structure, maybe you can include { } and ; at some parts.

 

http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary196.html

Edited by skyhook
Link to comment
Share on other sites

Indeed. Your if() has two lines after it, but no braces, so only the first line is considered to be inside the if(). Then, a couple of lines later, the parser sees an else, but the if() has already ended. You need to do this:

 

{
var num1:Number = 0.5;
if(num < num1)
{
   	mc_enemy.y += 20
   	num = Math.random()
} else { 
   	mc_enemy.y -= 20
   	num = Math.random()
}
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.