Multiline comments

Use multiline comments, also called block comments, for comments that are several lines in length. Developers commonly use multiline comments to describe files, data structures, methods, and descriptions of files. They are usually placed at the beginning of a file and before or within a method.

To create a comment block, place /* at the beginning of the commented lines and */ at the end of the comment block. This technique lets you create lengthy comments without adding // at the beginning of each line. Using // for numerous sequential lines can lead to some problems when you modify the comments.

The format for a multiline comment is as follows.

/*
    The following ActionScript initializes variables used in the main and sub-menu systems. Variables are used to track what options are clicked.
*/

TIP

If you place the comment characters (/* and */) on separate lines at the beginning and end of the comment, you can easily comment them out by placing double slash characters (//) in front of them (for example, ///* and //*/). These let you quickly and easily comment and uncomment your code.

By placing large chunks of script in a comment block, called commenting out a portion of your script, you can test specific parts of a script. For example, when the following script runs, none of the code in the comment block executes:

// The following code runs.
var x:Number = 15;
var y:Number = 20;

// The following code is commented out and will not run.
/*
// create new Date object
var myDate:Date = new Date();
var currentMonth:Number = myDate.getMonth();
// convert month number to month name
var monthName:String = calcMonth(currentMonth);
var year:Number = myDate.getFullYear();
var currentDate:Number = myDate.getDate();
*/

// The code below runs.
var namePrefix:String = "My name is";
var age:Number = 20;

TIP

It's good practice to place a blank line before a block comment.