Groups | Blog | Home
all groups > macromedia flash flashcom > march 2005 >

macromedia flash flashcom : Initialise SharedObjects on the server


CDXX
3/14/2005 12:18:10 AM
It seems pretty simple, but I've just spent 4 hours trying to make it work, and
it won't! I'm creating a SharedObject in application.onAppStart(), and setting
a property. I want this to be an initial state that the first client finds when
accessing the SharedObject. So I create client code that connects and reads the
property using xxx.data.myProperty. The return value is not what I'm expecting.
In fact it's always undefined. I've checked the documentation for calling a
remote SharedObject, and implemente it as far as I can see. Curiously, if I
call a client function from the server application.onConnect() to return the
value of the SharedObject property, it is correct. Can anyone help? I feel
ashamed at not being able to get up the first step.
Berzy
3/14/2005 12:54:20 AM
can you post the code... I can help you out but i need to be able to look over it..
CDXX
3/14/2005 8:42:41 AM
Thank you for helping. Server side code is: application.onAppStart =
function() { server_so = SharedObject.get('server_so', true);
//server_so.onSync = onSyncTemplate; server_so.setProperty('currentStream',
({broadcaster: 'No Broadcaster'})); server_so.setProperty('slot1', '11');
server_so.setProperty('slot2', '22'); trace (server_so.getProperty('slot1')); }
Client-side is: function setupSharedObject(nc){ so =
SharedObject.getRemote('server_so', nc.uri); // Set up the shared object.
so.ready = false; // Create the onSync handler. so.onSync = function(list){ //
Check if this is the first time onSync has been called // and create the array
if one doesn't exist already. if (! this.ready){ this.ready = true; } for
(var i in list){ var obj = list; for (var p in obj){ trace('so.onSync> ' + p +
': ' + obj[p]); } } trace ('URI = ' + nc.uri);
trace('so.data.currentStream.broadcasterName = ' +
so.data.currentStream.broadcasterName); trace ('this.ready = ' + this.ready);
trace('so.data.slot1= ' + so.data.slot1); trace ('this.ready = ' + this.ready);
} so.connect(nc); }
Berzy
3/14/2005 1:05:58 PM
your scope is wrong..... instead of so.data.slot1 it would be this.data.slot1 .....

hope that helps
CDXX
3/14/2005 8:48:45 PM
I'm grateful for your help, and I can see that this wouldn't have worked. For a
moment I cursed my own idiocy, but, unfortunately , even after trying:
trace('this.data.currentStream.broadcasterName = ' +
this.data.currentStream.broadcasterName); trace ('this.ready = ' +
this.ready); I still get : URI = rtmp://localhost/myHello/myInstance
this.data.currentStream.broadcasterName = undefined this.ready = true I am a
..Net developer who has done a lot of .Net and Flash MX Remoting, and I am blown
away by the possibilities of Communication Server. But taking so long just to
do something so simple is, well, so frustrating. But thanks again.
CDXX
3/14/2005 9:02:06 PM
I discovered the problem. I had the persist object parameter set to false on
the client, and true on the server. Setting both to true finally worked. Wow.
Great technology, difficult IDE. Thanks Berzy. Saved my forebrain.
AddThis Social Bookmark Button