开发者

Finding correct scope of an Object for a callback

I'm working on writing a tweening class in as2 that has a callback variable and I can't seem to find a good way to get the scope without specifically passing in a scope variable as well. This tweening class needs to work in classes as well as on the timeline. Here's what my codes looks like right now.

params.scope[ params.onComplete ]( params.onCompleteParams );

params is an object passed into the class. This works but I don't want to hav开发者_Python百科e params.scope in there.

My question is, what do I need to do in the tweening class to make sure I have the correct scope for the callback function without useing params.scope?


A function doesn't know about its scope in AS2 - it doesn't contain any reference to it, unless you add one. You will have to use a scope object as you are doing.

Try looking at Function.call, Function.apply, or the mx.utils.Delegate class for other ways to handle scope and methods which don't involve square brackets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜