
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
208
|
Chapter 9: Functions
Built-in Functions
Although we’ve seen how to create user-defined functions, let’s not forget that
ActionScript comes with a bevy of built-in functions (akin to verbs in our language
analogy). We’ve already seen some built-in functions that allow us to manipulate
data. We’ve also touched on functions that control the Flash movie and the user
environment.
For example, to manipulate the playhead of a movie clip, we can call the
gotoAndPlay() function with a frame number as a parameter:
gotoAndPlay(5);
If you are a new programmer, you may be experiencing an epiphany. I hope you have
noticed that you invoke built-in functions using the function-call operator (the
parentheses) and an argument list (the value 5 in this case) just like our custom user-
defined functions! Built-in functions, such as gotoAndPlay(), are used just like the
functions we’ve been declaring ourselves. Custom functions typically do something
that a built-in ActionScript function doesn’t already offer. Like any custom function,
each built-in function has a name, zero or more optional or required arguments, and
a return value (although sometimes the value is
undefined).
Even though Flash has long referred to gotoAndPlay as an “Action,” we now see it in
its true form, as a built-in function. In Chapter ...