AS3共享对象管理器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3共享对象管理器相关的知识,希望对你有一定的参考价值。
Credit for this goes to Terry Paton
package { import flash.net.SharedObject import flash.utils.Dictionary; public class SharedObjectManager { public function SharedObjectManager():void { _instance = this } public function setupSharedObject(_string:String):void { // setup the shared object if it doesn't exist already so = SharedObject.getLocal (_string) } public function getData(_string:String):Object { var _data:Object = so.data[_string] return _data } public static function getInstance():SharedObjectManager { return _instance } public function setData(_key:String,_val:*):void { so.data[_key] = _val save() } public function save():void { // save the shared object so.flush() } public static var _instance:SharedObjectManager public var so:SharedObject public var storage:Object public var dictionary:Dictionary } } // Usage Example // // import SharedObjectManager; // var _sharedOBJ:SharedObjectManager = new SharedObjectManager(); // _sharedOBJ.setupSharedObject ("test"); // // set the data // _sharedOBJ.setData ("lives",3); // // get the data // trace (_sharedOBJ.getData ("lives"));
以上是关于AS3共享对象管理器的主要内容,如果未能解决你的问题,请参考以下文章