6
CHAPTER 6
Functions and Methods
Understanding functions is important when you're writing ActionScript, creating classes, and
using methods.There are several different kinds of functions that you'll work with. In this
chapter, you learn about functions and methods: how to use them in your applications when
you use built-in classes, and how to write them. In
Chapter 7, "Classes,"
you'll create custom
classes in which you'll write functions regularly. You'll also learn how to write functions in
ActionScript class files.
You can use functions in your code to add interactivity, animations, and other effects to your
applications. This chapter covers the kinds of functions that you can write in your Flash
applications. For information on what functions and methods are, as well as exercises in which
you write and use functions and methods in Flash, see the following topics:
About functions and methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Understanding methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222
About functions and methods
Methods and functions are blocks of ActionScript code that you can reuse anywhere in a SWF
file. You might write your functions in the FLA file or in an external ActionScript file and
then call the function from anywhere within your documents. Methods are merely functions
that are located within an ActionScript class definition. You can define functions to execute a
series of statements on passed values. Your functions can also return values. After a function is
defined, it can be called from any timeline, including a timeline of a loaded SWF file.
201
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?