# How to use a shared object

**URL:** <https://forum.kirupa.com/t/how-to-use-a-shared-object/330593>\
**Category:** flash\
**Created:** [February 14, 2013, 6:51pm UTC](https://forum.kirupa.com/t/how-to-use-a-shared-object/330593 "2013-02-14T18:51:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashnve](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@flashnve](https://forum.kirupa.com/u/flashnve)\
**Post date:** [February 14, 2013, 6:51pm UTC](https://forum.kirupa.com/t/how-to-use-a-shared-object/330593/1 "2013-02-14T18:51:20Z")

</div>

I’m trying to use a remote shared object to send data messages between the client and server using the sharedobject.send method for a chat application.  
I am really having difficulty understanding the documentations. The code i attempted to use simply didn’t work.

Can someone be kind enough to show me the relevant API calls? And, take a close inspection at my code and tell me were exactly i am going wrong?  
Thank You.

Client-Side  
import flash.net.NetConnection;  
import flash.events.NetStatusEvent;  
import flash.events.SyncEvent;

var nc:NetConnection = new NetConnection();

nc.connect(“rtmfp://fms/exampledomain”);

nc.addEventListener(NetStatusEvent.NET\_STATUS, netHandler);

function netHandler(event:NetStatusEvent):void{  
if(event.info.code == “NetConnection.Connect.Success”){  
trace(“Your Connected”);

//Creating the sharedobject  
var my\_so:SharedObject = SharedObject.getRemote(“users”, nc.uri, false);

my\_so.connect(nc);

my\_so.addEventListener(SyncEvent.SYNC, syncHandler);

my\_so.setProperty(“users”);

my\_so.setDirty(“users”);

function syncHandler(event:SyncEvent):void{  
var changelist:Array = event.changeList;

}

my\_so.send function sendMessage(str){

Server-Side  
application.onConnect(clientObj)(){  
application.acceptConnection(clientObj){  
trace(“connected up”);  
}

var my\_so = SharedObject.getRemote(“users”, false);  
my\_so.send(“Hello user”, “Its only a test”);  
}
