eMx
eMx

Reputation: 81

Flex 4.5 iOS Mobile Project : SharedObject problems

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?

Upvotes: 3

Views: 2387

Answers (2)

eMx
eMx

Reputation: 81

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!

Upvotes: 5

Jonathan Rowny
Jonathan Rowny

Reputation: 7588

First of all, you should use encryption if you're storing passwords. I'm not sure on your LSO issue, but I think Local Encrypted Store may be an answer and I think it is supported with iOS and AIR 3.0. You can also use an encrypted SQL Lite database. This answer has some info on that: EncryptedLocalStore not supported

EDIT: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/EncryptedLocalStore.html

According to documentation this is supported on everything but TVs. So all mobile should now have EncryptedLocalStore but you'll need to switch to Air3.

Upvotes: 0

Related Questions