• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

What am i doing wrong

Guest
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

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

nc.connect("rtmfp://localhost/msgShared");                                                     

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

//process the str object

Server

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

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

Views

506

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 12, 2013 May 12, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 13, 2013 May 13, 2013

Copy link to clipboard

Copied

LATEST

Hi,

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

          nc.connect("rtmfp://localhost/app_name");

}

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.addEventListener(SyncEvent.SYNC,onSyncEvent);

                    so.client = new Object();

                    so.client.doSomething = doSomething;

                    so.connect(nc);

          }

}

public function onSyncEvent(evt:SyncEvent):void

{

          trace("sync called");

          nc.call("callMethod",null);

}

function doSomething(str) {

          trace("In doSomething : "+str);

}

Server Side:

application.onConnect = function(client){

          trace("In onConnect");

          application.acceptConnection(client);

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

          client.callMethod = function() {

                         trace("In callMethod.");

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

          }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines