Flash JSFL 外部接口问题
我无法通过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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我使用的是 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.