Syntax
Syntax is the way a sentence is organized. In programming, a "sentence of code" is called a statement. The form of your statement must adhere to strict syntax rules or it won't work. One such rule is that an open parenthesis must be followed by a closing parenthesis.
example:
gotoAndPlay( won't work
gotoAndPlay() works
Flash uses dot syntax. You connect objects, methods, and properties with dots.
Ex. object with a property set
dog._weight=12
Ex. object with a method called (dog's timeline is going to
play starting on frame 2
dog.gotoAndPlay(2);
Semicolon: used between statements
to terminate a statement
Curly braces: used to relate blocks of statements
such as multiple instructions for one button
Commas: separate the parameters of a method
Parenthesis: parameters go inside parenthesis
ex.
on (release){
stopAllSounds();
gotoAndPlay("Scene 1", 20);
}
note: you can check syntax from the top right pull down menu of the actions panel and selecting Check Syntax.
note2: Actionscript is CASE SENSITIVE.
note3: Slash syntax was used in Flash 3 & Flash 4. Don't be alarmed if you see slashes. It is still supported by Flash Player 7, but not recommended as Actionscript 2.0 doesn't recognize it.
Syntax Color Coding
Flash also helps you with syntax by color
coding certain items (this can be customized in the Flash Preferences).
Defaults:
-things built into the preset actions in Flash
will show up as blue
-properties are green.
-comments (notes which are ignored by Flash that are for others to read to understand your code) are pink.
-Anything you type between quotation marks is gray
You can tell when you have typed something in correctly because it turns the proper color.