PDA

View Full Version : SSAS, FCS - Returning Value to Client SWF


CrazyRaven
09-27-2005, 06:22 PM
I'm trying to find a way to do something very simple... I want the client swf to trigger a function on the FCS and return a value. Now, I'm not a stupid guy, but everywhere I've looked I get examples that make no sense...

I think I've found 2 key ingredients... netConnection.call and client.call... but no real clear way of understanding how they work

I would assume that you from the client you:
thisvariable = nc.call(functionname);

and on the server in the main.asc you:

function functionname(){
return somevalue;
}

but there seems to be some need for:
Client.call(functionInClientSWF, "argumentvalue")

Can anyone give me an example of from a SWF client, calling a function on the FCS that returns a value to the client... say the application.userList.length

PLEASE HELP!!!

jaci
09-29-2005, 07:53 AM
Hi,

I have made the swf file call a function on the server side(main.asc) on click of a button and also send response back to client.

The following is the client side(fla file) coding:

_root.nc = new NetConnection();

//server calls this function on the client side to send back the value
_root.nc.sending_value = function(len)
{
trace("Response from the server: Total clients connected :"+len);
}
_root.nc.onStatus = function(info)
{
trace(info.code);

}

_root.nc.connect("rtmp://localhost/test/");

my_btn.onRelease = function()
{

//call to server
_root.nc.call("request_value",null);

}

//Server side coding(main.asc)

application.onConnect = function (client_obj)
{

//function request value

client_obj.request_value = function()
{
var len = application.clients.length;

// call back the function sending_value on the client

this.call("sending_value",null,len);


}
}

To summarize this...

1. First we establish the connection _root.nc
2.on click of my_btn we trigger th function request_value on the server side..
3.server sends its response "application.clients.length" to "sending_value" on the client side..

Hope this helps..
Many thanks,