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 長春語林科技 閱讀(197) 評論(0)  編輯  收藏 所屬分類: flex
          <2011年3月>
          272812345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

           

          長春語林科技?xì)g迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 慈溪市| 休宁县| 乌兰县| 邳州市| 金门县| 磴口县| 潮州市| 锡林浩特市| 鄂托克前旗| 宁陕县| 建宁县| 昌都县| 沐川县| 新晃| 汽车| 灵寿县| 枞阳县| 盐山县| 阿图什市| 肥乡县| 剑河县| 达尔| 和田县| 陇西县| 定西市| 海林市| 辽宁省| 蒲城县| 安陆市| 乌恰县| 哈巴河县| 南安市| 永平县| 河北省| 弥勒县| 延边| 湾仔区| 潞城市| 安平县| 乌审旗| 尚志市|