actionscript-3flashshared-objectslocal-shared-object

AS3: How to detect the local storage popup window in Flash?


When I flush a local SharedObject that is over 100KB, this popup window appears asking the user to allow or deny storing information onto their computer if they haven't already allowed it. How can I detect when the popup appears and when it goes away and which button the user clicked on? I saw some other Flash game that had it's own internal information box appear whenever that popup came up, and disappear when it disappeared. How can I do something similar?

enter image description here


Solution

  • It turns out that the popup in question is not quite the same thing as the Security Panel. When you call sharedObject.flush(), it returns SharedObjectFlushStatus.FLUSHED if it was successful, or SharedObjectFlushStatus.PENDING if it wasn't and the popup appears. You can do sharedObject.addEventListener(NetStatusEvent.NET_STATUS,allowOrDeny) to see what the user clicked on. The popup disappears and the netStatusEvent.info.code will be either "SharedObject.Flush.Success" or "SharedObject.Flush.Failed". It's all documented rather nicely here.