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

Chapter 6. Functions and Methods > About functions and methods

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.

If you pass values as parameters to a function, the function can perform calculations using the supplied values. Each function has individual characteristics, and some functions require that you pass certain types or numbers of values. If you pass more parameters than the function requires, the function ignores the extra values. If you don’t pass a required parameter, the function assigns the undefined data type to the empty parameters. This can cause errors during runtime. A function can also return values (see “Returning values from functions” on page 225).


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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