Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
This chapter is from the book

More on Punctuation

Dot syntax allows you to construct meaningful processes and assignments with objects, properties, and methods. Additional punctuation symbols let you do more with these single statements.

The semicolon

To terminate individual ActionScript statements and start new ones, you use the semicolon. The semicolon functions as a period does in a sentence: It concludes one idea and lets another one begin.

stopAllSounds ();
play ();

The semicolons separate the statements, so that all the sounds stop first; then the movie begins to play. Each statement is executed in order from the top down, like a set of instructions or a cookbook recipe.

TIP

Flash will still understand ActionScript statements even if you don't have the semicolons to terminate each one. It is good practice, however, to include them in your scripts.

Curly braces

Curly braces are another kind of punctuation that ActionScript uses frequently. Curly braces group related blocks of ActionScript statements. When you assign actions to a button, for example, those actions appear within curly braces in the on (release) statement.

on (release) {
	stopAllSounds ();
	play ();
}

In this case, both the stopAllSounds action and the play action are executed when the mouse button is released. Notice how the curly braces are separated on different lines to make the related ActionScript statements easier to read.

Commas

Commas separate the parameters of a method. A method can take many parameters. The gotoAndPlay () method, for example, can take two: a scene name and the frame number. With commas separating the parameters, the ActionScript code looks like this:

gotoAndPlay ("Scene 1", 20);

Some methods may have three, four, or perhaps even 10 parameters, but as long as you separate the parameters with commas, Flash knows how to handle the code.

  • + Share This
  • 🔖 Save To Your Account