I'm trying to interface ActionScript with JavaScript using ExternalInterface and webpack.
ExternalInterface can only provoked (call) functions found on the global object (window). How can I get a webpack module reference on window (global object)?
Allow me to elaborate some, I want to have a namespace for the company (window.companyName) with an interface for ExternalInterface:
window.companyName = { isReady: function() { ... },
driver1: function() { ... },
driver2: function() { ... } }
The ActionScript will drive my JavaScript. The more fundamental question is, how do I set globals using webpack so that ExternalInterface can see them (preferably as exports of a module)?
I've tried using expose-loader, exports-loader imports-loader with no luck. expose-loaderis ideally what I need, but doesn't seem to work. When I set window.companyName in my modules and try to verify it in my chrome console, it results in undefined.
You do have access to window object from your webpacked script. Webpack does not interfere with it since the wrapper function only injects
module,exportsand__webpack_require__arguments.Try it writing a script with a single line accessing window object and then check out the output script.
Your assignment should work, unless the execution never reaches it or some loader is altering the relevant code.