Skip to main content
Participant
July 27, 2006
Question

Remote Shared Object

  • July 27, 2006
  • 1 reply
  • 263 views
I want to create a shared object which contains an array of objects. I want to have functions the client can call to add, delete, and update items in the shared object, but there do not seem to be any mechanisms for that. Anyone have any ideas I would greatly appreciate it.

Thanks,

Chester
    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    July 28, 2006
    You can store objects, or arrays of objects in a shared object property. The server side code would look something like this:

    my_so = SharedObject.get("someSharedObject", false);
    myObject = new Object();
    myObject["childObject1"] = new Object();
    myObject["childObject2"] = new Object();
    my_so.setProperty("somePropertyName", myObject);

    So, now you have a property in the shared object named somePropertyName, and its value is and object with two child objects. If you then wanted to manipulate the object, you would do something like this:

    myObject = my_so.getProperty("somePropertyName");
    var someVar="someValue";
    myObject.childObject1["somevar"] = someVar;
    my_so.setProperty("somePropertyName", myObject);

    What we did here was read the value of the shared object property into a variable, add a variable to one of the child objects, and write the parent object back into the shared object property.

    A shared object can have as many properties as you need (a shared object is still an object after all), you you can use separate properties to manage separate arrays or arrays of objects.