Flash应用的本地缓存以及AS3单例模式

package {
	import flash.net.SharedObject;

	public class LocalCache {
		
		private var cache:SharedObject;
		private static var _instance:LocalCache;

		public function LocalCache(singletonEnforcer:SingletonEnforcer) {
			if(singletonEnforcer==null){
				throw new Error("singletonEnforcer");
			}else{
				cache = SharedObject.getLocal("proposal");
			}
		}
		
		public static function getInstance():LocalCache {
			if(LocalCache._instance == null) {
				LocalCache._instance = new LocalCache(new SingletonEnforcer());
			}
			return LocalCache._instance;
		}
		
		public function putValue(key:String,value:Object):void {
			cache.data[key]=value;
			cache.flush();
		}
		
		public function getValue(key:String):* {
			return cache.data[key];
		}
		
		public function clear():void {
			cache.clear();
		}
	}
}
class SingletonEnforcer {}

 

 

* Windows XP:
         o For Web sites: C:\Documents and Settings\<user>\Application Data\Macromedia\Flash Player\#SharedObjects\<random code>\<domain>\<path>\<object name>.sol
         o For AIR Applications, C:\Documents and Settings\<user>\Application Data\<AIR Application Reverse Domain Name>\Local Store\#SharedObjects\<flash filename>.swf\<object name>.sol
   * Windows Vista
         o C:/Users/username/<user>/AppData/Roaming/Macromedia/Flash Player/#SharedObjects/<domain>/<path>/<flash filename>.swf/<object name>.sol
   * Mac OS X:
         o For Web sites, Macintosh HD:Users:<user>:Library:Preferences:Macromedia:Flash Player:#SharedObjects:<random code>:<domain>:<path from webserver>\<object name>.sol
         o For AIR Applications, Macintosh HD:Users:<username>:Library:Preferences:<AIR Application Reverse Domain Name>:Local Store:#SharedObjects:<flash filename>.swf\<object name>.sol
   * Linux/Unix:
         o /home/<User>/.macromedia/Flash_Player/#SharedObjects/<domain>/<path>/<flash filename>.swf/<object name>.sol

 

AS3单例模式参考:http://life.neophi.com/danielr/2006/10/singleton_pattern_in_as3.html

你可能感兴趣的:(linux,cache,XP,Flash,AIR)