Flash / AS3:ExternalInterface.call()“为什么你没有console.log?”

时间:2011-07-14 16:20:11

标签: javascript flash actionscript-3 externalinterface

我正在尝试进行一个非常简单的测试,以便为我提供AS3 ExternalInterface.call()到Javascript console.log()。

我在顶层有一个简单的带有AS3的SWF和一个触发呼叫的按钮。

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");
}

我已经在Flash IDE中对此进行了测试,以确保按钮单击是跟踪,它是。我一直在最新的Chrome和Firefox浏览器中测试它。

我做了一些根本错误的事吗?

1 个答案:

答案 0 :(得分:3)

尝试过同样的尝试!适合我。确保你的addEventListener代码在一个像创建完成的函数中。应该是。

另请参阅http://code.google.com/p/flash-thunderbolt/

相关问题