Okay, i havent ever looked at the proxy class but i think i can take a stab at answering some of your questions, others can probably back me up / correct me on any errors.
1. Yes it appears he could have used slice, perhaps using the for loop is quicker? 2. There are occasions when you want to pass the returning functions extra parameters. When using the Macromedia Delegate class i came accross times when it would have been neater to supply additional paramters, but it wasnt essential. Im sure somone else can give you a specific example of when its needed. Mike On 09/06/06, js <[EMAIL PROTECTED]> wrote:
I was taking a look recently at the Proxy class created by Joey Lott of Person13 for educational purposes, as I have just started learning OOP, and a couple questions popped into my mind. Here is the full class: class ascb.util.Proxy { public static function create(oTarget:Object, fFunction:Function):Function { var aParameters:Array = new Array(); for(var i:Number = 2; i < arguments.length; i++) { aParameters[i - 2] = arguments[i]; } var fProxy:Function = function():Void { var aActualParameters:Array = arguments.concat(aParameters); fFunction.apply(oTarget, aActualParameters); }; return fProxy; } } First of all, when populating aParameters, why couldn't you just do: aParameters = arguments.slice(2); That seems a lot more clean and improves readability a bit, no? Second, why exactly do you need to concat the arguments of fProxy and aParameters? I can see what it's doing; it's tacking on the additional arguments supplied to Proxy.create onto the arguments of the fProxy function (which is then returned) -- but I can't really envision a situation where that would be needed? For instance: class someClass { private var _someMc:MovieClip; function someClass(mc:MovieClip){ _someMc = mc; _someMc.onRelease = Proxy.create(this,someMethod,1,2,3); } private function someMethod(a,b,c){ trace(a+" "+b+" "+c); } } In what case would I be calling someMethod() via Proxy and supplying a set of arguments that do not match the syntax of someMethod()? It seems to me that you could just replace the following: var aActualParameters:Array = arguments.concat(aParameters); fFunction.apply(oTarget, aActualParameters); with: fFunction.apply(oTarget, aParameters); Any clarification or insight is greatly appreciated. Joseph Sorensen aerosdesign.com/jsorensen jsorensen[at]aerosdesign.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com