In a recent project, i was asked to build a system that would support storing cookies on a user’s local machine. This is obviously solved with SharedObjects if you’re working with the Flash Player. However, i ran into a few issues with this and found out a few interesting things.

Firstly, i wanted to detect if the user allows Flash/Flex to write to their computer. This can be solved as follows:

You can use the flush function of the SharedObject class… mySharedObject.flush(1) where 1 is the number in bytes that you require for your SharedObject. If the function returns a value of SharedObjectFlushStatus.PENDING, there is not sufficient space to store your SharedObject and a dialog appears that prompts the user to rectify this. If the function returns false, however, the user has not permitted using SharedObjects.

To call up a user’s Flash settings dialog (Camera, Display, Storage, Microphone, Privacy, Settings Manager), you would use the Security class from the flash.system package.