AS3方法调用javascript + NO SERVER COMMUNICATION

时间:2015-04-22 14:31:13

标签: javascript actionscript-3 externalinterface

下面的代码是我的jscript,我相信我在集成代码时没有任何错误。

<script type="text/javascript" src="./js/swfobject.js"></script>

<script type="text/javascript">
var flashvars = {};
var params = {};
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "map-moa";
swfobject.embedSWF("./video/map.swf?v=1.3", "map-moa", "1560", "980", "9.0.0", false, flashvars, params, attributes);
</script>

$(".goto-path").on("click",function(){
    // alert("goto booth #"+$(this).data('booth_id'));
    sendTextToAS3(); // call Flash (AS3) Method
});

function sendTextToAS3(){
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    var flash = (isIE) ? window["map-moa"] : document["map-moa"];
    console.log(flash)
    try{
    flash.sampleMethod();
    }catch(e){
        console.log(e)
    }
}

我有一个错误作为未定义的方法但该函数在我的as3类中正确声明。

public function Main():void { ExternalInterface.addCallback("sampleMethod", callbackID); }
public function callbackID():void { trace(this, "TEST"); }

0 个答案:

没有答案