Skip to main content
Participant
March 18, 2010
Question

Problem with shareobject.send()

  • March 18, 2010
  • 1 reply
  • 1555 views

I have a problem with shareobject. the Send method does not work. I work with AS3


My code

Server :

application.onAppStart = function()
{
  this.text_so = SharedObject.get("text_so", false);
}

application.onConnect = function(client)

  this.acceptConnection(client);
  this.text_so.send("MandarMensaje","OK");

}

Client:

.........

.......

                text_so=SharedObject.getRemote("text_so",nc.uri,false);
                text_so.connect(nc);
                text_so.client=this;


                text_so.MandarMensaje = function() {

                    trace('');

                   
                };

.......

......

This code have a error , I need an example of function definition is executed from the server.

    This topic has been closed for replies.

    1 reply

    March 19, 2010

    Hi,

    In your client side function you have not declared

    text_so.MandarMensaje = function() {

                        trace('');

    }

    Here you have not declared an argument, while on the server side you are also sending an parameter "OK" with the function call SO.send("fnName","OK");

    So you try replacing the client side definition as

    text_so.MandarMensaje = function(info) {

                        trace(info);

    }

    If you still face problems, please revert back and also state the error you are getting. Also on the server side try checking the return value of the SO.send method to see if it returns true or false.

    Thanks,

    Abhishek

    Participant
    March 22, 2010

    Thank AbhishekSinha

    But the problem is with the definition of the function within the class, I returned error:

    1119: Access a MandarMensaje possibly undefined property through a reference with static type flash.net: SharedObject.

    The problem is not to define the function inside the class.

    Class:

    package {

        import flash.net.NetConnection;
        import flash.events.NetStatusEvent;
        import flash.net.SharedObject;
        import flash.display.Sprite;

        public class TV extends Sprite {
            private var nc:NetConnection;
            private var rtmpNow:String;
            private var SERVER:String="localhost";
            private var text_so:SharedObject;
            private var good:Boolean;

            public function TV() {

                nc=new NetConnection()  ;

                nc.addEventListener(NetStatusEvent.NET_STATUS,checkConnect);

                rtmpNow="rtmp://"+SERVER+"/studio/";

                nc.client=this;

                nc.connect(rtmpNow);

            }


            private function checkConnect(e:NetStatusEvent) {
                trace(e.info.code);
                good=e.info.code=="NetConnection.Connect.Success";
                if (good) {
                   
                    text_so=SharedObject.getRemote("text_so",nc.uri,false);
                    text_so.connect(nc);
                    text_so.client=this;

     
                    text_so.MandarMensaje = function(info) {
                    trace(info);
                    };


                }
            }

        }

    Thanks

    March 22, 2010

    Ok, so you are using an AS3 client. Sorry I missed it in your first post.

    Use:

    text_so.client = new object();

    text_so.client. MandarMensaje = function(info) {

                    trace(info);

                    };

    This should solve your problem

    Thanks,

    Abhishek