好的,所以可以将一个函数传递给另一个函数。
Passing a function to another function in Actionscript 3
这显然非常强大,但更重要的问题是,什么时候这样做才有意义,因为无论何时调用另一个函数都会产生性能开销?
最佳答案
如果您有很多 ActionScript 知识,您可能会一直使用这样的一个示例,甚至没有注意到。
EventDispatcher 类的 addEventListener 实际上需要在调用时传入一个函数:
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
http://livedocs.adobe.com/flex/3/langref/flash/events/EventDispatcher.html
传递函数在回调中被大量使用。还有许多其他用途,但这突出了更简单的场景之一。
关于actionscript-3 - 什么时候将函数传递给函数才有意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1855711/