O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Functions

A function, or more specifically a function closure, is a discrete set of instructions that carry out some task, independent of any class or object. Function closures have the same basic syntax and usage as instance methods and static methods; they are defined with the function keyword, can define local variables, are invoked with the parentheses operator, and can optionally return a value. However, unlike instance methods (which are always associated with an object) and static methods (which are always associated with a class), function closures are created and used in standalone form, either as a subtask in a method, or a general utility available throughout a package or an entire program.

Tip

In the strict technical jargon of the ActionScript 3.0 specification, function closures and methods are both considered types of functions, where the term function refers generally to a callable object representing a set of instructions. Thus, a function closure is a function that is not associated with an object or a class, while a method is a function that is associated with an object (in the case of instance methods) or a class (in the case of static methods). However, in common discussion and most documentation, the term function closure is shortened to function. Unless you are reading the ActionScript 3.0 specification or a text that specifically states otherwise, you can safely assume that function means function closure. In the remainder of this book, the term function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required