javascript Flash/AS3:ExternalInterface.call() “为什么你没有 console.log?”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6696579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Flash/AS3: ExternalInterface.call() "Why u no console.log?"
提问by
I'm trying to do a very simple test to get the AS3 ExternalInterface.call() to Javascript console.log() for me.
我正在尝试做一个非常简单的测试,以便为我将 AS3 ExternalInterface.call() 转换为 Javascript console.log()。
I have a simple SWF with AS3 on a top layer and a button that triggers the call.
我有一个简单的 SWF,顶层带有 AS3,还有一个触发调用的按钮。
import flash.external.ExternalInterface;
function log(message:String):void
{
trace (message);
if (ExternalInterface.available)
{
ExternalInterface.call('console.log', message);
}
}
button.addEventListener(MouseEvent.CLICK,button_click);
function button_click(e:MouseEvent):void
{
log("Hello World");
}
I have tested this in the Flash IDE to make sure the button click is tracing and it is. I've been testing this in both the latest Chrome and Firefox browser.
我已经在 Flash IDE 中对此进行了测试,以确保按钮单击正在跟踪并且确实如此。我一直在最新的 Chrome 和 Firefox 浏览器中对此进行测试。
Am I doing something fundamentally wrong?
我在做一些根本错误的事情吗?
回答by Satish
tried the same! works for me. Make sure your addEventListener code inside a function like creation complete. it should be.
试过一样!对我来说有效。确保像创建这样的函数中的 addEventListener 代码完成。它应该是。
Also look at http://code.google.com/p/flash-thunderbolt/