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


Macromedia Flash Communication Server MX
Macromedia Flash Communication Server MX
ISBN: 0735713332
EAN: 2147483647
Year: 2002
Pages: 200
Authors: Kevin Towes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net