ProxyClass.prototype.__resolve = function(methodName){
trace("Didn't find "+methodName+" resolving...");
if(this._obj[methodName] instanceof Function)
return function(){
this._obj[methodName].apply(this._obj,arguments);
}
else(this._obj[methodName]!=undefined)
return this._obj[methodName];
}
Just a little example of allowing a proxy object to not only fetch methods correctly but also properties. Couple notes, I don't just return the method directly, I use the apply method on it. This is so the method will run in the correct scope. Second thing, you can easily get in infinite loops when assigning properties to your class if you do not set them ot null or some other value in the prototype.
I also have a version of this that will look at the object see if it has the method or property and if not, make a call to the server for it.
7:28:56 PM
|