I recently discovered the .apply() method that every function offers , which allow to call a function passing the parameters through an array, so you can descide at runtime whose and how many paramters pass. ( functionName.apply(null,paramArray) )
For sure it works with Actionscript declared function, but what if I want to call a method of a remote object?
I've tried to invoke remoteObject.method.apply(null,myParametersArray) but at runtime Flash returns:
ReferenceError: Error #1069 impossible to find the apply property on mx.rpc.remoting.mxml.Operation
I'm wondering if there's some other way to perform this.
What I'm trying to achieve is:
Define a form inside flex in design mode
Create a class which , given the id of the form and the id of the remote object , reads all the value inside the form and parse a remote call to a method defined in my remote PHP class (which is already coded for accepting a variable number of parameters)
If this would work, then it could be apply to any forms i design so I would only have to design the form and apply the class to it. ( very nice....)
Have you ever tried to do this?
Any suggestion would be really appreciated.
Thanks in advance.
I solved my problem and I want to share with you my solution.
Instead of calling remoteObject.method.apply(null,paramArray) whichi raised an error ('cause the remote method isn't seen by flex as an istance of the function class), I call remoteObject.getOperation("method").send.apply(null,paramArray). The .send() is an istance of the function class so you can use the apply() method.
Hope this help.