2 Replies Latest reply: May 13, 2013 1:36 AM by Chandan_Abhishek RSS

    What am i doing wrong


      I have a couple of questions in regards using the SharedObject. I want to send a string message using the send method () on the shared object.  I'm  keeping everything in the fla file for now.  I copied the bulk of the code from a documentation just to test it. When I run the application I get an error 1119: access of undefined property doSomething .Which I can't resolve. I want to get more information about it.  My final question is,  do I receive any kind of notification if the string message  succeeded or failed? Thank You  


      var nc:NetConnection = new NetConnection();          


      var so:SharedObject = SharedObject.getRemote("foo", nc.uri, true); so.connect(nc);                                                                 so.doSomething = function(str) { 

      //process the str object



      var so = SharedObject.get("foo", true);

      so.send("doSomethng", "this is a test");

        • 1. Re: What am i doing wrong
          md140 Community Member

          No reply..Bad question or just a tough question.

          • 2. Re: What am i doing wrong
            Chandan_Abhishek Adobe Employee



            Before trying to access any property in AS3, first you need to define it. Also, if server is calling SharedObject.send(), then the menthod will be invoked only on the clients which are connected to that shared object before the SharedObject.send() has been invoked on the server. Following is the working code for the same. In the below code, after connection is successful, SharedObject.connect() is called which in turn invokes "onSyncEvent" handler. It means connection to shared object has been made, and there a server side function is called which in turn calls the SharedObject.send().


            Client Side:

            public function test() {

                      // constructor code

                      nc = new NetConnection();

                                nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);




            function netHandler(event:NetStatusEvent):void {

                      trace("In onNC "+event.info.code);

                      if(event.info.code === 'NetConnection.Connect.Success') {

                                so = SharedObject.getRemote("foo", nc.uri, true);



                                so.client = new Object();

                                so.client.doSomething = doSomething;





            public function onSyncEvent(evt:SyncEvent):void


                      trace("sync called");




            function doSomething(str) {

                      trace("In doSomething : "+str);




            Server Side:

            application.onConnect = function(client){

                      trace("In onConnect");


                      so = SharedObject.get("foo",true);

                      client.callMethod = function() {

                                     trace("In callMethod.");

                                     so.send("doSomething", "This is a test");