MKI*_*KII 9 flash anonymous function actionscript-3
我遇到过它们,但我还没有明白为什么要使用它们.有人可以解释一下吗?
Sat*_*Sat 11
当你不需要为这个功能命名时,在闭合中使用它很舒服.I. e.这条路:
var myFunc : Function = function() : void {trace("Hello world!");}
doSomething(myFunc);
Run Code Online (Sandbox Code Playgroud)
或这个:
button.addEventListener(MouseEvent.CLICK,
function(e : MouseEvent) : void
{
// doSomething
});
Run Code Online (Sandbox Code Playgroud)
您不必使用它们,但如果它更容易,您可以使用它们.