9Organizing Code with Functions
Functions
Functions are used to assemble statements into meaningful, logical functional units — hence the name, Function. Even simple applications can have a large number of individual statements. Without functions, code would be unruly and unreadable.
ActionScript 2 code exists primarily in the form of classes. The methods of classes are functions. As explained in Chapters 5–7, classes take the idea of modular, reusable code to the next level and provide a way to group functions and variables together into logical units.
Defining Functions
Whether they are part of a class or simply defined on a timeline, functions are constructed in the same way. A function definition has three main elements:
- The function Declaration ...
Get Understanding Macromedia Flash 8 ActionScript 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.