Connect and Create a Remote SharedObject (Flash)

Listing E.9 will connect the Flash client to a persistent remote SharedObject. If the object does not exist, it will be created. There is a simple read and write sample included.

Listing E.9 Flash ActionScript for Creating a Remote SharedObject
initRemoteSharedObject = function () {
      trace("Connect a Remote SharedObject");
      rem_so = SharedObject.getRemote("myRemoteSO", nc.uri, true);

      // Note: the following onSync event uses the onSync template script
      rem_so.onSync = onSyncTemplate;

      // Write properties (slots) to the Remote SharedObject = "FlashCom will change the world!"; = ["Brett", "Mike", "Ryan", "Paul", "Jody", "Kevin"];

      // Read properties (slots) from a Remote SharedObject
      var my_var =;
      var my_array =;
      trace(" Remote SharedObject Read Test: "+my_var);
      trace(" Remote SharedObject Read Test: "+my_array[0]);
      trace("Remote SO Size: "+rem_so.getSize());

    Part I: 10 Quick Steps for Getting Started