I’m trying to use a SharedObject in a Flex 4.5 mobile project.
The SDK I’m using is 4.5.1, and the AIR version is 2.6.0.
I’m trying to locally store user credentials for my application using this piece of code:
var so:SharedObject = SharedObject.getLocal("cred");
so.data.user = txtUser.text;
so.data.password = txtPass.text;
so.data.rememberMe = isLoginRemembered.selected;
var result:String = so.flush();
Afterwards, when the application loads again,
I’d like to use my previously saved SharedObject credentials, so the user doesnt need to input his credentials every time.
var so:SharedObject = SharedObject.getLocal("cred");
txtUser.text = so.data.user;
txtPass.text = so.data.password;
isLoginRemembered.selected = so.data.rememberMe;
But this doesn’t seem to work, the user & password were never saved, and thus null.
If I go looking for the cred.sol file on my file system (Mac OSX), I cant even find the file!
This all whilst the ‘result’ string says “flushed”.
I’m developing this app on a Mac and would like to deploy to iOS.
Any suggestions?
I solved the problem!
I’m developing this app using Flash Builder 4.5, and I made a debug/run configuration for iPhone4.
Now, when you’re specifying a run/debug configuration, you can select a checkbox ‘Clear application data on each launch’. This checkbox needs to be UNCHECKED, because this will clear your SharedObject on each application launch!
To access this configuration screen in Flash Builder 4.5, click the tiny arrow next to your run/debug button and click Run/Debug Configurations. Navigate to your specified configuration, and uncheck the checkbox!
Voila! Enjoy your iOS SharedObject awesomeness!