Here is the script:
function delay(pFunc:Function):Void {
this.onEnterFrame = function() {
pFunc(param);
delete this.onEnterFrame;
};
}
delay(test, 1);
function test():Void {
trace(this); //traces "[object Object]"
}
It’s stripped down to reproduce my issue.
I want to change the scope of the event, so that when test is called, it traces "_level0 instead of “[object Object”. I was thinking Delegate.create() would be the way to go, but I can’t figure out how to get that to work within the scope of this function. I know what is happening, I’m just not sure how to fix it.
If I could just do it in AS3 it wouldn’t be an issue, but it’s AS2, c’est la vie.