views:

299

answers:

2

I've seen a number of very informative articles explaining that SharedObject.getLocal will return null if it can't find or create the requested SharedObject, but can find anything telling me why this method would fail. Does anyone want to take a stab at it?

A: 

you mean, finding out at runtime, why the operation failed? you can't ...

either the path you gave is malformed, or you cannot access the object, because it is secure, and your swf is not ... or simply because the user disallowed the usage of shared objects ... and possibly other reasons ...

back2dos
A: 

Unfortunately, what back2dos said above is correct - basically Flash will tell you that the creation failed, but not why it failed. However, you can try make an educated guess as to why it might have failed, and then prompt the user to do something about the failure if needed.

If you can't get an empty SharedObject (SO) when first requesting it, and the path you supplied is correct, then it's likely that the user may have disabled them. If writing the object fails, you can measure the size of the SO you're trying to write, and then if it's over the default 100KB limit, then you could ask the user to increase their storage space. Also, when writing your SOs using SharedObject.flush(), you can specify the size the SO will need, and if that space isn't available, the Flash Player will display the dialog asking the user to increase their storage space.

If the user needs to either allow SharedObjects, or increase the storage space allowed, you can offer to open the Flash Player settings panel for them to make the changes needed:

Security.showSettings(SecurityPanel.LOCAL_STORAGE);
joshbuhler