Skip to content

Instantly share code, notes, and snippets.

@lynxerzhang
Last active August 16, 2019 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynxerzhang/0c94f48aade15c334761067eafcc3d08 to your computer and use it in GitHub Desktop.
Save lynxerzhang/0c94f48aade15c334761067eafcc3d08 to your computer and use it in GitHub Desktop.
calling anonymous js (不需要额外书写js)
package utils
{
import flash.external.ExternalInterface;
//@see https://code.tutsplus.com/tutorials/quick-tip-how-to-communicate-between-flash-and-javascript--active-3370
public class JS_LocalStorage
{
public function JS_LocalStorage()
{
}
public static function save(_key:String, _value:*):void
{
try{
ExternalInterface.call("function(key, value) {window.localStorage.setItem(key, value); }", _key, _value);
}
catch(e:Error){
}
}
public static function read(_key:String):*
{
try {
var result:* = ExternalInterface.call("function(key) {return window.localStorage.getItem(key); }", _key);
return result;
}catch(e:Error){
}
}
public static function contain(key:String):Boolean
{
var result:* = read(key);
return result != null && result != undefined;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment