Skip to main content
Inspiring
September 16, 2007
Question

from as2 to as3

  • September 16, 2007
  • 3 replies
  • 431 views
Hi,

I'm migrating a chat application I develped in AS2 to As3 (flash cs3).
I can not find how to call a client function from the server.
In AS2 I used:



myNetConnection.myClientFunction = function() {
//do something
}


I have tried adding an eventlistener but it doesnt work.

Any ideas? thanks
    This topic is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    Inspiring
    October 2, 2007
    Yah very important point from NetDragon. As of version 3.0 the netconnection " class was dynamic in ActionScript 2.0 but is now sealed. " so you can't just do something like:

    netconnection.client.somefunction = function() {...}

    The default netconnection.client = this, so you need to extend it with a custom class or an object to be able to add callback functions

    But be careful, I wrote an entire app that worked with the AS2.0 technique ...without an error from the compiler.....(flex 2.0).
    September 20, 2007
    the NetConnection has a property called client, this property in an object of set of function that you can call from the server
    check this code:

    var clientCallBacks:Object = new Object();
    clientCallBacks.setUserNameAndServerId = onSetUserNameAndServerId;
    connection.client = clientCallBacks;

    now I can call "setUserNameAndServerId" from the server and at client the function "onSetUserNameAndServerId" will be run.

    I hope that help ...
    Inspiring
    September 20, 2007
    you using ...call(); or send(); ??