views:

135

answers:

1

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?

A: 

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.

John Wright
Have a look at MMExecute as well
George Profenza