Chapter 26. Using Functions and Arrays

IN THIS CHAPTER

  • Data typing in ActionScript

  • Strict typing in ActionScript 2.0

  • Using functions in ActionScript

  • Adding arrays to manage data

  • Creating dynamic menus

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.

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 straightforward. One of the difficult aspects of working with data types is knowing which data types work correctly with the operation you want to perform in ActionScript. We will show you examples throughout this ...

Get Adobe® Flash® CS3 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.