views:

47

answers:

1

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 have 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: 

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.

tarling