Swiz supports two ways for client persistence. If you have a web project you can use the SharedObjectBean and for AIR SharedObjectBean and/or EncryptedLocalStorageBean (not committed yet).
SharedObjectBean
To use the SharedObjectBean you have to declare it in a BeanLoader:
<?xml version="1.0" encoding="utf-8"?> <swiz:BeanLoader xmlns:swiz="http://swiz.swizframework.org" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:storage="org.swizframework.storage.*"> <fx:Declarations> <storage:SharedObjectBean id="soBean" /> </fx:Declarations> </swiz:BeanLoader>
Inject the instance into your model and declare a bindable getter/setter:
[Autowire] public var so:ISharedObjectBean; [Bindable] public function get appIndex():int { // the second parameter is the initial value return so.getInt("appIndex", 0); } public function set appIndex(index:int):void { so.setInt("appIndex", index); }
For further information please check the ASDocs at http://swiz.github.com/
{ 1 } Comments
These classes are not in the current binary release (0.6.2) but appear to work fine if droped into the correct directory structure in your project.