astro geek Posted December 4, 2010 Posted December 4, 2010 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?
skyhook Posted December 4, 2010 Posted December 4, 2010 (edited) 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 December 4, 2010 by skyhook
Cap'n Refsmmat Posted December 4, 2010 Posted December 4, 2010 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() } }
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now