AS3函数指针 [英] as3 function pointer
本文介绍了AS3函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private function myFunction(numIn:Number){
trace ("numIn " + numIn);
}
var plan:Object = { "theFunctionName": "myFunction" }
// now use the function
plan.theFunctionName(5);
// should trace out: "numIn 5"
这是行不通的,但你可以看到我想要做什么?这有点像一个函数指针,或者当你通过一个函数名到事件侦听器。谢谢。
This won't work, but can you see what I'm trying to do? It's kind of like a function pointer, or when you pass a function name into an event listener. Thanks.
推荐答案
你需要的是:
var plan:Object = { theFunctionName: myFunction }
这篇关于AS3函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文