Skip to content

Instantly share code, notes, and snippets.

@quakeboy
Last active December 29, 2015 15:09
Show Gist options
  • Save quakeboy/7689159 to your computer and use it in GitHub Desktop.
Save quakeboy/7689159 to your computer and use it in GitHub Desktop.
Saving and loading AS3 classes from SharedObjects
private var so:SharedObject = SharedObject.getLocal("Demo");
public function saveResClass(cls:Class):void
{
this.storeValue("lastClass", getQualifiedClassName(db));
}
public function loadResClass():Class
{
var className:String = so.data["lastClass"];
var c:Class;
if (className &&
className != "")
c = getDefinitionByName(className) as Class;
else
trace ("No class saved previously");
return c;
}
public function storeValue(key:String, value:Object):void
{
so.data[key] = value;
so.flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment