all groups > macromedia flash flash remoting > january 2004 >
You're in the

macromedia flash flash remoting

group:

Service Call using a Dynamic Method name



Service Call using a Dynamic Method name MacroProd
1/28/2004 9:48:49 PM
macromedia flash flash remoting: Hello;

I have a service set up, and I want to be able to call a method on my service using a variable that has been typed into a text field... so let's say that the following line produces a result from the server:

_parent.flashService.getData("tcas", "SELECT RVT_DESC FROM ACU_RVT", "0", "ALL");

I would like to make the same EXACT call, only this time using a variable for getData("tcas", "SELECT RVT_DESC FROM ACU_RVT", "0", "ALL"), such as:

_parent.flashService[myMethodName];

Only, that does NOT work... PLEASE... any help?

Thank you!

Re: Service Call using a Dynamic Method name mlabriola
3/14/2004 10:00:28 PM
I was curious if an answer was found to this as I was hoping to do the same.

Here is what I have done, perhaps someone can tell me where I am goign wrong:

gatewayConnection = NetServices.createGatewayConnection(
"http://www.myserver.net/flashservices/gateway" );
server = gatewayConnection.getService( "my_cfc", this );
method_name = eval( "server." + 'getMyInfo' );
trace( method_name );
method_name.call(this);

Where getMyInfo would be a dynamic named based on other data. Interestingly
enough, my trace statement shows [type Function], which in my head means it at
least understands what I am getting at. However, if I watch the NetConnection
debugger, I get the connect to my server, but the method is never invoked. I
believe I understand why, but I was hoping that someone would have found a way
to do this.

Does anyone at Macromedia read these forums as a lot of really good questions
do go unanswered?

Thanks for any help,
ML
Re: Service Call using a Dynamic Method name mlabriola
3/14/2004 11:08:10 PM
P.S. This does work and it works pretty well. I am going to start a new thread
on a related topic, but to finish this one off, here is the deal on
NetConnection.call:

gatewayConnection = NetServices.createGatewayConnection(
"http://www.myserver.net/flashservices/gateway" );
gatewayConnection.call( "directory.cfc_name", this );

A few things to notice:

First, you do NOT need to call getService. The service name appears to be
encapsulated in the .call function.

Second, make sure the first parameter of your .call is the FULL path, in dot
notation, to the cfc you wish to call, from the web root.

Third, the last param is the responder. In this case, I simply made it the
object that was instantiate the connection, this, however, the param can be any
object that can handle OnResult and OnStatus events.

Fourth, which I am going to start a new thread on, I have not figured out a
way to pass a variable number of parameters, like the Actionscript
function.apply method.

Good Luck,
ML
AddThis Social Bookmark Button