Think of functions as the organizers of Macromedia Flash MX. They group related ActionScript statements to perform a specific task. Often you need to write code to perform certain tasks over and over again. Functions eliminate duplication of code because the code can remain in one place, and you can call on it wherever and whenever you wish. Functions are blocks of reusable code that can be passed certain parameters and will return a value. Following is an example of a function that returns the square of parameter z : function sqr(z) { Return z * z; }
|