16.8. Checking for Updates to Remote Shared Objects

Problem

You want to be able to efficiently check to see what data has changed when a remote shared object is synchronized.

Solution

Use the list parameter that is automatically passed to the onSync( ) method. Loop through the parameter to locate all the elements in which the code property has the value indicating the type of update you are interested in.

Discussion

When the onSync( ) method is invoked (see Recipe 16.6), it is automatically passed a parameter that contains information about how the data has changed. The parameter is an array of objects, one for each property of the remote shared object. For example, if a remote shared object has two properties named myDate and myArray (meaning my_r_so.data.myDate and my_r_so.data.myArray), then the list parameter passed to the onSync( ) method will have two elements. In turn, each element contains three properties: code, name, and oldVal. One element will have its name property set to “myDate”, and the other will have its name property set to “myArray”. The code property can have the following values for persistent shared objects:

“success”

The server-side value was successfully updated from a change made by this client.

“reject”

The client tried to make a change to the value, but it was rejected by the server—usually because the same object was being updated by another client.

“change”

The client-side value has been updated based on a new value from the server.

“delete”

The property has been ...

Get Actionscript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.