Skip to content

ExternalInterface

When a SWF calls ExternalInterface.addCallback, the callback becomes a method of the element. When it calls ExternalInterface.call, the call runs in the page as it did under Flash’s plug-in. allowscriptaccess decides whether a SWF may do either:

// The SWF: ExternalInterface.addCallback("setScore", setScore);
// ExternalInterface.call("onLevelDone", 3, { stars: 2 });
window.onLevelDone = (level, result) => console.log(level, result.stars);
const movie = document.querySelector("swf2es-player");
await movie.ready;
movie.setScore(120); // arrays and objects go both ways; the call is synchronous

The page’s calls into the SWF need no eval. Any SWF that runs can reach the page through another’s code, so on a page that mixes trusted and untrusted SWFs, do not give script access to any of them (why).