Use SharedObject to transfer data : SharedObject « Data Model « Flex






Use SharedObject to transfer data

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

1.Create a SharedObject
2.Access a SharedObject Between Multiple Flash ApplicationsAccess a SharedObject Between Multiple Flash Applications
3.Optimize a Runtime Shared LibraryOptimize a Runtime Shared Library