Syntax 31
Curly braces
ActionScript event handlers, class definitions, and functions are grouped together into blocks
with curly braces (
{}). You can put the opening brace on the same line as your declaration or on
the next line, as shown in the following examples. To make your code easier to read, it’s a good
idea to choose one format and use it consistently.
// Event handler
on(release) {
myDate = new Date();
currentMonth = myDate.getMonth();
}
on(release)
{
myDate = new Date();
currentMonth = myDate.getMonth();
}
// Class
class Circle(radius) {
}
class Square(side)
{
}
// Function
circleArea = function(radius) {
return radius * radius * MATH.PI;
}
squareArea = function(side)
{
return side * side;
}
You can check for matching curly braces in your scripts; see “Checking syntax and punctuation”
on page 66.
Semicolons
An ActionScript statement is terminated with a semicolon (
;), as shown in these examples:
var column = passedDate.getDay();
var row = 0;
If you omit the terminating semicolon, Flash still compiles your script successfully. However,
using semicolons is good scripting practice.