【问题标题】:Flash/AS3: ExternalInterface.call() "Why u no console.log?"Flash/AS3:ExternalInterface.call()“为什么你没有 console.log?”
【发布时间】:2011-07-14 16:20:11
【问题描述】:

我正在尝试做一个非常简单的测试,为我将 AS3 ExternalInterface.call() 转换为 Javascript console.log()。

我有一个简单的 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");
}

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

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

【问题讨论】:

    标签: javascript flash actionscript-3 externalinterface


    【解决方案1】:

    试过了!为我工作。确保您的 addEventListener 代码在创建之类的函数中完成。应该是的。

    也看http://code.google.com/p/flash-thunderbolt/

    【讨论】:

    • 另一个可能的陷阱: 确保在浏览器中使用http 或https 访问.swf 文件——如果您使用file:// 访问文件系统,这个ExternalInterface 调用似乎不起作用(至少对我而言)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 2014-04-08
    • 2019-01-20
    • 1970-01-01
    • 1970-01-01
    • 2016-08-17
    相关资源
    最近更新 更多