读书人

利用SharedObjects保留信息

发布时间: 2012-08-26 16:48:06 作者: rapoo

利用SharedObjects保存信息

??????? flash没有像html的cookies,但是通过SharedObjects可以实现类似的功能。

?

??????? 创建SharedObjects并保存用户名称

???????

//create a shared object to store the user name this line actually//specifies the file name (userFile), it will have an extension of .sol ...var so:SharedObject = SharedObject.getLocal("userFile");//create and populate a userLoginName property for the shared object...so.data.userLoginName = txtUserLoginName.text;//write the file to the users disk...so.flush();

?

??? 从SharedObjects中读取数据

?

??

var so:SharedObject = SharedObject.getLocal("userFile");if(so.data.userLoginName != undefined){    this.txtUserLoginName.text = so.data.userLoginName;    this.txtPassword.setFocus();}

?

?

? 删除SharedObjects中的信息

?

?

??

so.clear();so.flush();

?

?

读书人网 >Web前端

热点推荐