This is the personal weblog of Greg Burch.

Thursday, August 01, 2002

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    comment []


© Copyright 2003 Greg Burch.
 
August 2002
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Jul   Sep

Home

Articles
Live Previews
Common Component Issues
Flash Remoting
SharedObjects
FlashVars
Extending Components
__resolve and apply
XML 2 DataProvider

Macromedia WebLogs
Jeremy Allaire
mesh on mx
jd on mx
An Architect's View

Other WebLogs
Peter Hall
Eric Dolecki
Flash the Future
jdb cyberspace
Branden Hall
OnRelease
Josh Dura
moik78
Full As A Goog
Flash Magazine
Claus Wahlers
Arul Kumaran
Phillip Torrone
Quasimondo
Guy Watson
Robert Hall


Resources
Macromedia Mobile Development Center

Books
Flash Design for Mobile Devices

Flash Enabled

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.