
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
The ActionScript Statements
|
151
play(); // Plays the current movie
gotoAndStop(5); // Sends the playhead to frame 5
startDrag("crosshair", true); // Makes the "crosshair" instance follow
// the mouse pointer
Function calls are also used with objects to invoke methods:
circle.getArea();
today.getDate();
Because movie clip instances are objects, we frequently use method invocation in our
scripts:
ball_mc.play()
intro_mc.gotoAndStop("end");
We’ll cover the use of functions in Chapter 9, and in Chapter 12 we’ll see how func-
tions can become object methods.
The return Statement
When we call a function, we can optionally pass it one or more values (parameters or
arguments) to manipulate during execution. Likewise, a function can send us back a
return value (a value that results from the execution of a function and is sent back to
the caller). Within the body of a function, we use the return statement to conclude
the function’s execution and optionally return a value. A return statement takes one
of the following forms:
return;
return expression;
The optional expression, if included, becomes the return value of the function. A
return statement without a return value exits the function and returns the value
undefined. All return statements exit the current function. Note that return state-
ments are ...