
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Statement Syntax
|
145
Statements that declare variables
var
set
Statements that declare, call, and return values from functions
function
function call
return
Statements that deal with objects
with
for . . . in
Statements that represent a data value
any expression (especially expressions with side effects)
These informal categories help us understand what we can tell the interpreter to do
using statements. At first glance, the list may seem fairly limited. However, we’ll see
that there are many variations of conditionals and loops and that there are thou-
sands of things we can do with function calls. First, let’s see how statements are
formed.
Statement Syntax
Statements are typically made up of keywords and expressions. We’ve already seen
the var statement, which declares, and optionally, initializes a variable. Here’s an
example of the var statement’s general syntax:
var numFrames;
The keyword (var in this case) begins the statement. Each keyword is followed by the
syntax (parentheses, parameters, operands, etc.) required to complete the statement,
which, in our example, is simply the name of a variable,
numFrames. Finally, a semico-
lon marks the end of the statement.
In ActionScript, every statement should end with a semicolon, which
is not to say that there is one semicolon per line of the