Flash CS3 Documentation |
|||
| Learning ActionScript 2.0 in Adobe Flash > Functions and Methods > About functions and methods > About types of methods and functions > About function literals | |||
A function literal is an unnamed function that you declare in an expression instead of in a statement. Function literals are useful when you need to use a function temporarily or to use a function in your code where you might use an expression instead. The syntax for a function literal is:
function (param1, param2, etc) {
// statements
};
For example, the following code uses a function literal as an expression:
var yourName:String = "Ester";
setInterval(function() {trace(yourName);}, 200);
|
NOTE |
|
When you redefine a function literal, the new function definition replaces the old definition. |
You can store a function literal in a variable to access it later in your code. To do so, you use an anonymous function. For more information, see Writing anonymous and callback functions.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000752.html