An anonymous function , if called directly, is bound to a global object. If you trace thisinside it, you will see [object global]instead [object B]what it would be if it applies to b.
A common workaround is to use a closure:
var self:A = this;
return function():void {
if(self is C) {
trace("C");
} else {
trace("not C");
}
}
, , , , . , .
Amarghosh:
, this , , . :
package {
import flash.display.Sprite;
public class Test extends Sprite {
private var foo:String = "foo";
public function Test() {
var anonymous:Function = function ():void {
trace(foo);
trace(this.foo);
};
anonymous();
}
}
}
Greetz
back2dos