The only way for a client to call a method is for that method to exist
on the Client's object. That's just the way the Flash RPC stuff
works. You can either add it to the Client prototype (which I don't
like) or add it to the client object after they connect (my preferred
way).
For instance:
application.onConnect = function(oClient, oParams) {
this.acceptConnection(oClient);
oClient.helloServer = function() {
trace("Hello Server");
};
}
Or, you can get fancy and do some delegate-style work so that your
actual function is defined on application (or some other object):
application.helloServer = function() {
trace("Hello Server");
}
application.onConnect = function(oClient, oParams) {
this.acceptConnection(oClient);
oClient.oScope = this;
oClient.helloServer = function() {
this.oScope.helloServer.apply(this.oScope, arguments); };
}
The reason you're getting an error about the function not existing is
that it doesn't. When the client makes a call the server looks for a
function of the given name on the client's object. If it doesn't
exist you get an error.
I hope that helps!
-Andy
On 8/8/07, [p e r c e p t i c o n] <[EMAIL PROTECTED]> wrote:
> hi Andy,
> the server logs indicate that the method isn't defined...
>
> however if i define it using Client.helloServer = function()
>
> it seems to work, but my concern is that this isn't really remote...i want
> the client to call the application's method
>
> thanks
>
>
> p
>
> On 8/8/07, Andy Herrman <[EMAIL PROTECTED]> wrote:
> >
> > Your syntax looks fine. What do you mean by "it isn't recognized as a
> > method"?
> >
> > -Andy
> >
> > On 8/8/07, [p e r c e p t i c o n] <[EMAIL PROTECTED]> wrote:
> > > Hi folks,
> > >
> > > i know htis isn't the fms list, but can anyone tell how to define a
> > method
> > > in the asc file... for example
> > >
> > > i tried to define a method like this
> > >
> > > application.helloServer = function()
> > > {
> > > trace("hello from server");
> > > }
> > >
> > > but it isn't recognized as a method...
> > >
> > > i'm trying to not have to define it on the client side as a member of
> > the
> > > NetConnection object...
> > >
> > >
> > > thanks
> > >
> > > p
> > > _______________________________________________
> > > [email protected]
> > > 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
> > >
> > _______________________________________________
> > [email protected]
> > 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
> >
> _______________________________________________
> [email protected]
> 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
>
_______________________________________________
[email protected]
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