I’m new to using shared objects in AS3 and came here looking for some advice with something I came across. I have been playing around with a shared object to get a feel for them. After setting a client’s write access on my media server to none, I tried to access it to see what would happen on the client end of the program. After the object syncs the console prints:
clear
12
15
It appears that since I tried to change the value AS3 seems to go in an endless loop printing the following
Error #2044: Unhandled NetStatusEvent:. level=error, code=SharedObject.NoWriteAccess
delete
undefined
15
over and over again until I close the program. Here is the code pertaining to this topic:
package {
import flash.net.SharedObject;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.SyncEvent;
public class SOTest// extends SharedObject
{
private var _sharedObject:SharedObject;
public function SOTest(objectName:String, nc:NetConnection)
{
_sharedObject = SharedObject.getRemote(objectName,nc.uri);
_sharedObject.addEventListener(SyncEvent.SYNC, onSOUpdate);
_sharedObject.connect(nc);
_sharedObject.client = this;
}
private function onSOUpdate(e:SyncEvent)
{
trace(e.changeList[0].code);
trace(_sharedObject.data.id);
_sharedObject.setProperty("id",15);
trace(_sharedObject.data.id);
}
}
}
My question related to all this is what would be the best way for me to handle this situation if a client tries to modify a shared object that they do not have access to? I guess what I mean is how can I catch this error and prevent sync event from firing infinitely?