Flex: how to determine if a user has forbidden to block a shared object

A simple question: how do I detect in actionscript if the user has blocked writing data to a shared object?

sharedObj = SharedObject.getLocal("rememberme"); 

This always returns a shared object, but the size is 0, even I blocked the shared object.

When I try to save data to a shared object and clear it, it gives me an error because the record is being blocked. So, what would be the right way to check if a shared object record is disabled?

 Error: Error #2130: Unable to flush SharedObject. 
+6
source share
1 answer
 var my_so:SharedObject = SharedObject.getLocal("mySpace"); var flushStatus:String = null; try { flushStatus = my_so.flush(); } catch (error:Error) { trace("Error...Could not write SharedObject to disk\n"); } if (flushStatus != null) { switch (flushStatus) { case SharedObjectFlushStatus.PENDING : trace("Requesting permission to save object...\n"); my_so.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus); break; case SharedObjectFlushStatus.FLUSHED : trace("Value flushed to disk.\n"); break; } } function onFlushStatus(event:NetStatusEvent):void { trace("User closed permission dialog...\n"); switch (event.info.code) { case "SharedObject.Flush.Success" : trace("User granted permission -- value saved.\n"); break; case "SharedObject.Flush.Failed" : trace("User denied permission -- value not saved.\n"); break; } my_so.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus); } 

If the shared object is locked, you can catch report an error again if 0 goes before SharedObjectFlushStatus.PENDING .

A SOURCE

+10
source

Source: https://habr.com/ru/post/896288/


All Articles