| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
yackity shmackity
Join Date: Jun 2001
Location: London, UK
Posts: 340
|
Im trying to store multiple levels of data in a shared object by using a reference to an array in the setProperty() method in server-side AS.
I know the data is going in cos I can trace it using the netConnection debugger. The probelm is reading the data out of the so on the client. Can anyone see whats going wrong?? heres the SS AS ActionScript Code:
heres the client side: ActionScript Code:
cheers for your help ![]() |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Nov 2007
Location: Mumbai
Posts: 1
|
Hi Matt,
I found your problem similar to mine. Here I have a small bit of information which could be useful to you in case you want to output, the array stored in a shared object present on the server. You could probably do two things for it!.. 1. Create a local object on the cleint side and sync it with your shared object on the server. 2. A better way... Connect to the server using a function msgfrmcleint() and then send it back to the client a message from the server called: msgfrom server() Here is the code for the second one...: Server Side:.... application.onAppStart = function() { trace("Begin sharing text"); // Get the server shared object 'users_so' application.users_so = SharedObject.get("ChatUsers"); // Initialize the history of the text share application.history = ""; // Initialize the unique user ID application.nextId = 0; } application.onConnect = function(newClient, userName) { // Make this new client's name the user's name newClient.name = userName; // Create a unique ID for this user while incrementing the // application.nextID. newClient.id = "u" + application.nextId++; // Update the 'users_so' shared object with the user's name application.users_so.setProperty(newClient.name, userName); // Accept the client's connection application.acceptConnection(newClient); // Call the client function 'setHistory,' and pass // the initial history newClient.call("setHistory", null, application.history); // The client will call this function to get the server // to accept the message, add the user's name to it, and // send it back out to all connected clients. newClient.msgFromClient = function(msg) { msg = userName + ": " + msg + "\n"; application.history += msg; application.users_so.send("msgFromSrvr", msg); } } application.onDisconnect = function(client) { trace("disconnect: " + client.name); application.users_so.setProperty(client.name, null); application.users_so.flush(); } Cleint Side code is: private function sendMessage():void{ // call our remote function and send the message to all connected clients nc.call("msgFromClient", null, sendMessageInput.text); sendMessageInput.text = ""; } Now recieve the mesage here in the following: public function msgFromSrvr(msg:String):void{ writeMessage(msg); // Here you can obtain the data and use it elsewhere... } I hope this helped u.... dont mind if it didnt..!!! |
|
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|