利用SharedObjects保存信息

本文介绍如何利用Flash SharedObjects功能,实现类似于HTML cookies的数据存储和用户信息管理,包括创建、读取、更新及删除SharedObjects中的数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        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();

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值