Actionscript 委托函数麻烦... (myFunction).toString() 打印 function Function() {}
我有一个 ViewToActionMap
对象的向量,它具有以下构造函数:(
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
_withArgs:Array=null):void{
forModule = _forModule;
forAction = _forAction;
toFunction = _toFunction;
withArgs = _withArgs;
}
eModule
/ eViewAction
/ withArgs
are与我的帖子无关)
所以我的向量看起来像这样(为了简洁起见,我只包含了它的第一个对象..):
const actionMappings:Vector.<ViewToActionMap> = new <ViewToActionMap>
[new ViewToActionMap(eModule.WELCOME,
eViewAction.GP_CONTINUE_BUTTON,
startGame, //<--- the source of my troubles!
null)
]
其中 startGame
是一个简单的函数:
function startGame():void{ }
/////// //////// 所以这就是问题 ///////////////
如果我循环遍历 actionMappings[0] 的属性,这里是输出:
gpContinueButton
welcome
function Function() {} //<---------- why isn't this working?
null
为什么 .toFunction
一个空函数,而不是对 startGame() 的引用???
谢谢!
I've got a Vector of ViewToActionMap
objects, which have following constructor:
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
_withArgs:Array=null):void{
forModule = _forModule;
forAction = _forAction;
toFunction = _toFunction;
withArgs = _withArgs;
}
(eModule
/ eViewAction
/ withArgs
aren't relevant to my post)
So my vector looks like this (for brevity, i've only included its first object..):
const actionMappings:Vector.<ViewToActionMap> = new <ViewToActionMap>
[new ViewToActionMap(eModule.WELCOME,
eViewAction.GP_CONTINUE_BUTTON,
startGame, //<--- the source of my troubles!
null)
]
Where startGame
is a simple function:
function startGame():void{ }
/////////////// so here's the problem //////////////
if I loop through the properties of actionMappings[0], here is the output:
gpContinueButton
welcome
function Function() {} //<---------- why isn't this working?
null
Why is the value of .toFunction
an empty function, instead of a reference to startGame()????
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了:
似乎跟踪
".toFunction"
的值只会产生这样的结果:function Function() {}
一旦我修复了一个不相关的错误,我就能够调用startGame() 成功。
Solved it:
it seems that tracing the value of
".toFunction"
simply yields this:function Function() {}
Once i fixed an unrelated bug, I was able to call startGame() successfully.