Chapter 5. Writing Functions

Write a function

A function is nothing more than a reusable block of code. Functions are primarily designed to let you save development time. Rather than rewrite and retest similar code over and over, you can encapsulate the code into a function and then simply call it whenever you need its capabilities.

ActionScript includes a set of global functions to perform certain common tasks. Global functions are written into the core ActionScript code and can be accessed directly in your code.

One global function — trace — is covered in Chapter 2. Another common global function is stop, which is discussed in Chapter 8.

Most often, you will need some functionality that is specific to your project. In these cases, you will need ...

Get ActionScript®: Your visual blueprint™ for creating interactive projects in Flash® CS4 Professional 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.