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

Functions

Functions are a powerful aspect of ActionScript programming, allowing you to assign a name to a section of code that has a specific purpose, or functionality. Once you have defined and named a function, you can use it in other scripts simply by referencing its name. This is known as calling the function. Functions save coding time by eliminating the need to create redundant code to perform the same actions or sets of actions across your various scripts. With functions, you script once and use many times, similar to what symbols allow you to do graphically.

Defining and Calling a Function

Functions are simply statements similar to those discussed in the previous section. To define a function, you use the function keyword (accessible via the Actions panel by choosing Actions > Function), followed by the name you assigned to the function, followed by a closed set of parentheses. Then, the actions this function will perform are defined. Function names have the same requirements and restrictions as variable names.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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