Flash JSFL 外部接口问题

发布于 2024-08-20 15:23:00 字数 1122 浏览 8 评论 0原文

我无法通过ExternalInterface API 从 JSFL 调用 SWFPanel 来工作。我按照此处 如下所示:

在 SWF 面板中,在场景 1 操作 1 中,我使用ExternalInterface 注册回调函数:

ExternalInterface.addCallback("appendTrace", this, appendTrace);

function appendTrace(traceString:String):Void {
    trace("appendTrace");
    traceBox.text = traceBox.text + traceString;
}

然后在 JSFL 中,我迭代 swf 面板以找到 swf 面板,然后调用appendTrace 方法,如下所示:

appendTrace("Received trace");
fl.trace("got here");
function appendTrace(traceString) {
var panels = fl.swfPanels;
var myPanel;
for (var i = 0; i < panels.length; i++) {
    if (panels[i].name == 'MyPanel') {
        myPanel = panels[i];
        break;
    }
}
if (myPanel) {
    myPanel.call("appendTrace", traceString);
} else {
    fl.trace("Can't find Panel.  Is it installed?");
}
}

该行调用了 myPanel.call("appendTrace",traceString); ,但没有跟踪、附加任何内容,也没有抛出任何错误,因此看来ExternalInterface 没有调用appendTrace 方法。似乎一切都设置正确,但尝试了几件事但不起作用。这种方法有哪些常见问题?

I can’t get a call from JSFL to a SWFPanel to work via the ExternalInterface API. I am following the instructions here as follows:

In the SWF Panel, in scene 1 action 1, I register a callback function with ExternalInterface:

ExternalInterface.addCallback("appendTrace", this, appendTrace);

function appendTrace(traceString:String):Void {
    trace("appendTrace");
    traceBox.text = traceBox.text + traceString;
}

Then in my JSFL I am iterating through the swf panels to locate the swf panel and then invoking the appendTrace method as follows:

appendTrace("Received trace");
fl.trace("got here");
function appendTrace(traceString) {
var panels = fl.swfPanels;
var myPanel;
for (var i = 0; i < panels.length; i++) {
    if (panels[i].name == 'MyPanel') {
        myPanel = panels[i];
        break;
    }
}
if (myPanel) {
    myPanel.call("appendTrace", traceString);
} else {
    fl.trace("Can't find Panel.  Is it installed?");
}
}

The line myPanel.call("appendTrace", traceString); is called but nothing is traced, appended and no error is thrown so it appears that ExternalInterface isn’t calling the appendTrace method. It seems that everything is setup properly but have tried several things and it's not working. What are some common gotchas with this approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唠甜嗑 2024-08-27 15:23:00

问题是我使用的是 AS2 而不是 AS3。上述 SWFPanel→JSFL 通信需要 AS3 SWF 面板。当我切换到 AS3 后,它就工作了。

The issue was that I was using AS2 instead of AS3. The above SWFPanel<->JSFL communication requires AS3 SWF panels. Once I switched to AS3 it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文