
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Further ActionScript Concepts
|
13
Putting It All Together
Let’s review what you’ve learned. Here, again, is line one of our example:
var message = "Hi there, Flash!";
The keyword var tells the interpreter that we’re declaring (creating) a new variable.
The word
message is the name of our variable (a name we’ve chosen arbitrarily). The
equals sign is an operator that assigns the text string (“Hi there, Flash!”) to the vari-
able named
message. Hence, the text “Hi there, Flash!” becomes the value of message.
Finally, the semicolon (
;) tells the interpreter that we’re finished with our first state-
ment.
Line two is pretty much the same as line one:
var firstName = "your name here";
It assigns the text string you typed in place of your name here to the variable
firstName. A semicolon ends our second statement.
We reuse the variables
message and firstName in lines three and four:
trace (message);
trace ("Hi there, " + firstName + ", nice to meet you.");
The keyword trace tells the interpreter to display some text in the Output window.
We pass the text to be displayed as an argument. The opening parenthesis marks the
beginning of our argument. The trace( ) command requires one argument, but that
argument might be a fairly complex expression. For example, in line four, the argu-
ment includes two