An annoying typo (ActionScript 3.0 )

In the last days I’ve worked on the project Traced, in other words, I’ve coded pretty much in ActionScript3.0. It wasn’t bad at all, except a typo. It was nothing more than a small and boring semicolon, what I forgot to insert, but it just made my day … miserable. (Sorry, I feel, that the sentence “it made my day miserable” isn’t perfect, but I’m just a Hungarian guy, I hope you understand me, gentle reader.) So, I’ve debugged the following small typo for hours without any results:

var myString: String =
    "It is the first row, " +
    "it is the second row and "
    "it is the third row and" +
    "it is the fourth row.";

I treated the error in a very wrong way, I started to struggle with the debugger and I started to modify the program randomly instead of thinking. (Adding random modifications to the program is some sort of trial-and-error method, but sometimes I like to think that it is similar to car diagnostic. If your car doesn’t work and you are curious what is wrong with your car, likely you dismantle your car. That’s exactly what I do with my wrong programs. In this case, I dismantled my AS3 files for hours.)

I tend to promote that ActionScript 3.0 is almost the same like Java. (For example,here is a random blog article about this issue: “I was therefore pleasantly surprised to find that ActionScript 3 is actually quite a powerful language, and was syntactically similar to Java in many ways“. And here is a detailed analysis, its conclusion: “I think you’ll find that what Adobe has done is taken some of the lessons learned from what is right and wrong about Java and incorporated them into their development of the ActionScript 3.0 language.“) The typo of this article cannot cause headache in a Java program, because in Java, every statement must be terminated by a semicolon. But in ActionScript 3.0, the syntax is a bit different, see this: “Alternatively, if you omit the semicolon character, the compiler will assume that each line of code represents a single statement. Because many programmers are accustomed to using the semicolon to denote the end of a statement, your code may be easier to read if you consistently use semicolons to terminate your statements.

I remember, that the syntax of the new operator in AS3 is a bit different too and the C++-like int(myVar) casting notation is prefered, so I can mention at least three difference between AS3 and Java. I’m sure there are more differences. If I have more time, I will write a longer article about the differences.

Advertisements

About vrichard86

I'm Richard and I'm an enthusiastic coder. I want to be better and I think a professional journal is a great self improvement tool. Welcome to my blog, to my hq, to my home on the web!
This entry was posted in AS3 and tagged , , , , . Bookmark the permalink.