Chapter 25. Using Functions and Arrays

Now that you've had some practice applying ActionScript to MovieClip objects, you can start to explore the programming concepts behind subroutines and arrays. In this chapter, we introduce you to data types, subroutines, arrays, and complex uses of functions.

In previous chapters, you may have found yourself repeating the same actions (or type of actions) in several event handlers within a movie. Functions enable you to group actions into code blocks, referred to by custom names. Arrays are a different kind of grouping mechanism — instead of grouping actions, an array is used to group multiple items of data. Before we can discuss functions and arrays, however, you need to understand the types of data that are available in ActionScript.

Note

As discussed in past chapters, the event listener model of ActionScript 3.0 utilizes functions to process common events associated with interactive elements, such as button clicks and drag-and-drop behaviors.

What Are Data Types?

Simply put, ActionScript has several types of data that can be declared (or loaded) into the Flash movie. So far, you have worked primarily with three types of data in previous chapters: strings, numbers, and MovieClip objects. In this section, we define more data types available in ActionScript.

Understanding data types is rather ...

Get Adobe® Flash® CS4 Professional Bible 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.