/ Published in: ActionScript 3
Useful flash code.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
The SharedObject class is used to read and store limited amounts of data on a user's computer or on a server. Shared objects offer real-time data sharing between multiple client SWF files and objects that are persistent on the local computer or remote server. Local shared objects are similar to browser cookies and remote shared objects are similar to real-time data transfer devices. About how to save,get,delete date,we had do some code for you to understands.... Here is a save user , get user, delete user utils code. public class SharedObjectUtils { private static const LOCAL:String = "www.activetofocus.com"; /* get user list */ public static function getUserList():Array { var shareObject:SharedObject = SharedObject.getLocal(SharedObjectUtils.LOCAL); var arr:Array = shareObject.data; return arr; } /* save user */ public static function saveUser(userId:String,userName:String,userPassword:String):void { var shareObject:SharedObject = SharedObject.getLocal(SharedObjectUtils.LOCAL); var arr:Array = shareObject.data; var newArr:Array = []; if(arr != null && arr.length >0) { var k:int=0; for(var i:int = arr.length - 1; i>=0;i--) { if(arr[i].id != userId && k<2) { newArr.unshift(arr[i]); k++; } } } newArr.push({id:userId,name:userName,password:userPassword}); shareObject.data= newArr; shareObject.flush(); } /* delete user */ public static function deleteUser(userId:String):void { var shareObject:SharedObject = SharedObject.getLocal(SharedObjectUtils.LOCAL); var arr:Array = shareObject.data; var newArr:Array = []; if(arr != null && arr.length >0) { for(var i:int=0; i { if(arr[i].id != userId) newArr.push(arr[i]); } } shareObject.data= newArr; shareObject.flush(); } } from: http://activetofocus.com/blog/how-to-use-sharedobject-for-save-get-delete-date-27/
URL: http://activetofocus.com/blog/how-to-use-sharedobject-for-save-get-delete-date-27/