Tip:
Highlight text to annotate it
X
Functions are another important building block in creating Flash applications.
In this chapter, we are going to be talking about functions and how you can
create and use them in your applications. Functions are reusable blocks of code that
are used to perform repetitive tasks and that can group related functionality.
If I am going to relate functions to doing grocery shopping, just
like we related variables to doing grocery shopping. When you think of grocery
shopping, you may think of going to the store, grabbing your groceries, and coming
home. Grocery shopping, as well as just about any other errand that you can run, is
a group of related tasks. So in order to go grocery shopping, I need to
get in my car, go to the store, grab groceries off the shelf, and put them in the
cart, and buy them, and so on. Just like in ActionScript code, a function
like maybe a function related to going to the store would involve each of those
mini tasks. So throughout this chapter we will talk about all the syntax
for creating functions, and details about how to use them in your applications.