Friday, March 26, 2010

Syntax Error? Huh?

The following script is giving me a syntax error...?Any ideas?

Error:?''Scene=Scene 1, Layer=Nav Bar, Frame=1: Line 12: Unexpected '}' encountered }''

on(release)
{
if(_root.textVar != 1)
{
?for(int i = 0; i %26lt; 5; i++)
?{
unloadMovieNum(i);
?}
?_root.textVar = 1;
?loadMovieNum(''mc_TextBox.swf'', 0);

}

}

Syntax Error? Huh?

Most of the time when an error message points to the end of the code, something just about anywhere in the code tripped things up...

?for(int i = 0; i %26lt; 5; i++)

Try:

?for(i = 0; i %26lt; 5; i++)

Even if there was an int data type in AS2, the way you utilized it would not be correct.

Syntax Error? Huh?

.

Thanks for the answer.?It worked perfectly.?I still had a logic error, but I cleaned that up no problem.

Question, however:?You said that if ''int'' were a type in AS2, it still wouldn't work.

for(int i = 0; i %26lt; iALength; i++)?works fine in java...

did you just mean that you can't have ''int'' in the for loop in AS?

I hate saying can't, or doesn't, 'cause I sometimes find out I'm wrong, but that also means I learned something, so it's not so bad.?So let me step out on a limb and say, for what I know, AS2 does not have an int data type, just a Number type.?AS3 does have both int and uint data types.

If AS2 did have an int data type, it would be specified/utilized like any other data type is...

var i:int = 0;

or

int(i);

AS isn't java and does not caste variables with the type leading in as you did...?pretty much every instance/variable is created in the form of:

var varName:Class;

Ohhhhh.?Ok.?I see what you're saying.

Yea, I'm just learning this stuff (unfortunately on Flash MX...) and I didn't even know how to declare a variable type hehe.?Except to use ''_root.varName''

Thanks for the help.

You're welcome... being that you're using MX, the only time you need to really worry about defining types is when you need to get them to agreee with what you're trying to do.?I don't think I evenr defined the types up front.?I would usually just be doing something like Number(text_field.text) if I needed a string to suddenly become a number for a calculation.

AS3 is a different story though, and you almost always need to cast the type in order to get things working properly... even when the compiler can see the types that are involved, it will kick out errors simply because you didn't specifically designate them.

No comments:

Post a Comment