Skip navigation
Currently Being Moderated

What am i doing wrong

May 10, 2013 5:50 AM

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");

  • Currently Being Moderated
    May 13, 2013 1:36 AM   in reply to md140



    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 ";

              if( === '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");



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points