Internal 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. You hopefully will have noticed that you invoke built-in functions using the function-call operator (the parentheses) and a parameter 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 building ourselves. Naturally, the built-in functions do different things than our custom functions, and there is no sense in writing a custom function to do something that a built-in ActionScript function already offers. But like any custom function, each built-in function has a name, optional parameters, and a return value (although sometimes it’s undefined).

Even though Flash has long referred to gotoAndPlay as an “Action,” we now see it in its true form, as an internal function. In Chapter 6 we learned that some Flash Actions are statements and some are functions. Now that you’ve studied both thoroughly, you’ll be able to tell ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.