- 執行外部JS方法
ExternalInterface.call("your_js_function()");
OR
ExternalInterface.call("your_js_function"); - 執行外部JS方法並傳遞參數
ExternalInterface.call("your_js_function","HelloWorld"); - 執行外部JS方法並接收回傳值
var x:*=ExternalInterface.call("your_js_function");
實例:
- 彈出對話視窗
ExternalInterface.call("alert", "Hello World");
OR
ExternalInterface.call("function(){alert('something');}"); - 設定cookies
ExternalInterface.call("function(){document.cookie='random="+Math.random()+"'}"); - 取得cookies
var s:String=ExternalInterface.call("function(){ return document.cookie;}");
var cookies:Array = s.split(";");