• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Appendix: IV Appendixes: Quick Reference... > Connect and Create a Remote SharedOb...

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;
      rem_so.connect(nc);

      // Write properties (slots) to the Remote SharedObject
      rem_so.data.simpleTest = “FlashCom will change the world!”;
      rem_so.data.arrayTest = ["Brett", "Mike", "Ryan", "Paul", "Jody", "Kevin"];

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


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint