Use SharedObject to transfer data

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="230">
<mx:Script>
import mx.controls.Alert;
[Bindable]
public var user:SharedObject = SharedObject.getLocal("user");
private function setSharedObject():void{
if(this.rememberMe.selected){
user.data.firstname = this.firstname.text;
user.flush();
Alert.show("saved", "Alert");
}
}
private function clearSharedObject():void{
this.rememberMe.selected = false;
user.clear();
Alert.show("Your information has been cleared.", "Alert");
}
</mx:Script>
<mx:Panel title="Shared Object Sample">
<mx:Form>
<mx:FormItem label="Firstname:">
<mx:TextInput id="firstname" text="{user.data.firstname}" />
</mx:FormItem>
<mx:FormItem label="Remember Me" direction="horizontal">
<mx:CheckBox id="rememberMe" change="setSharedObject()" />
</mx:FormItem>
<mx:FormItem direction="horizontal">
<mx:Button label="Clear Shared Object" click="clearSharedObject()"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
</mx:Application>
Related examples in the same category