• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Functions > How to Use Functions

How to Use Functions

Functions involve two steps: writing the function and then using the function. I’m going to discuss using functions first, which might seem like I’m putting the cart before the horse. However, because Flash’s built-in functions are already written, it’s easy to look at using those. Also, this way, when you do write your own functions, you’ll already know how to use them. Suffice it to say that you can’t start using a homemade function unless you write it first…and if you just write a function (but never use it), nothing happens.

Using Built-In Functions

To get this far in the book, you’ve already learned something about the built-in functions. In addition to the brief explanation in Chapter 4, “Basic Programming in Flash,” you actually used a few functions in Chapter 5, “Programming Structures.” For example, to ensure that an expression was treated like the number data type, we used the Number() function, as in Number(anExpression). This evaluates the string “anExpression” as a number. If the expression in parentheses evaluated as "112", the entire expression (Number("112")) would evaluate as 112.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint