Flex 记住密码

1 在密码正确的情况下,如果“记住密码”是选中的,那么将用户名,密码和记住密码的状态保存 
var userInfoCookie:SharedObject = SharedObject.getLocal("userInfoCookie"); 
                        if(rememberPsw.selected) 
                        { 
                        userInfoCookie.data.userName = nameid.text; 
                        userInfoCookie.data.userPsw = passwordid.text; 
                        userInfoCookie.data.isRememberPsw = true; 
                        } 
                        else 
                        { 
                            userInfoCookie.data.userName = ""; 
                            userInfoCookie.data.userPsw = ""; 
                            userInfoCookie.data.isRememberPsw = false; 
                        } 
                        userInfoCookie.flush(); 
2 在加载登录界面时调用initialize="preInit()"方法: 
var userInfoCookie:SharedObject = SharedObject.getLocal("userInfoCookie"); 
                if(userInfoCookie.data.hasOwnProperty("userName") && userInfoCookie.data.isRememberPsw && userInfoCookie.data.userName != "") 
                { 
                    this.nameid.text = userInfoCookie.data.userName; 
                    this.passwordid.text = userInfoCookie.data.userPsw; 
                    this.rememberPsw.selected =  true; 
                } 

你可能感兴趣的:(Flex)