posts - 325,  comments - 25,  trackbacks - 0

使用共享对象记住用户名:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 backgroundColor="#FFFFFF" width="400" height="230">
  <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    [Bindable]
    public var user:SharedObject = SharedObject.getLocal("user");
    private function setSharedObject():void{
      // if checkbox is selected, create shared object data
      if(this.rememberMe.selected){
        user.data.firstname = this.firstname.text;
        user.data.lastname = this.lastname.text;
        user.flush();
        Alert.show("Your information has been saved, reload the application to see your saved information.", "Alert");
      }
    }
    // clear all data from the shared object
    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="Lastname:">
        <mx:TextInput id="lastname" text="{user.data.lastname}" />
      </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>

posted on 2011-03-16 10:42 长春语林科技 阅读(181) 评论(0)  编辑  收藏 所属分类: flex

只有注册用户登录后才能发表评论。


网站导航:
 
<2011年3月>
272812345
6789101112
13141516171819
20212223242526
272829303112
3456789

 

长春语林科技欢迎您!

常用链接

留言簿(6)

随笔分类

随笔档案

文章分类

文章档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜