O'Reilly logo

Adobe® Flash® CS3 Professional Bible by Snow Dowd, Robert Reinhardt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required