Last active
August 16, 2019 08:04
-
-
Save lynxerzhang/0c94f48aade15c334761067eafcc3d08 to your computer and use it in GitHub Desktop.
calling anonymous js (不需要额外书写js)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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