[AS3]as3的SharedObject简单应用SCookie
[AS3]as3的SharedObject简单应用SCookie
SCookie 只是SharedObject的一个简单应用,简化了SharedObject的使用,能够更方便一些管理本地数据。 对于经常用到本地数据存储的同学,也许能有一点点帮助....
使用方法
写入:
SCookie.setCookie("cookie名称" ,"cookie属性名",cookie属性的内容)
读取:
SCookie.getCookie("cookie名称","属性名称")
清除:
SCookie.clearCookie("cookie名称")
eg:
import com.sixuu.SCookie
SCookie.setCookie("test","name","liam")
SCookie.setCookie("test","sex","male")
SCookie.setCookie("test","age",22)
trace(SCookie.getCookie("test","name")) //liam
trace(SCookie.getCookie("test","sex")) //male
trace(SCookie.getCookie("test","age")) //22
- package com.sixuu {
- import flash.net.SharedObject;
- public class SCookie {
- public function SCookie() {
- }
- static public function setCookie(cookieName:String,propertyName:String,value:Object){
- var so:SharedObject=SharedObject.getLocal(cookieName,"/")
- so.data[propertyName]=value
- so.flush()
- }
- public static function getCookie(cookieName:String,propertyName:String )
- {
- var so:SharedObject=SharedObject.getLocal(cookieName,"/")
- //trace("cookie size is "+so.size)
- return so.data[propertyName]
- }
- public static function clearCookie(clearedCookieName:String )
- {
- var so:SharedObject=SharedObject.getLocal(clearedCookieName,"/")
- so.clear()
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例