I am working on a Flash project (network speed test) and want to use ExternalInterface.call() at each step of the way to communicate to the HTML page on what step the Flash project is right now.

The problem is that on each and every scene's Actions, I have to import ExternalInterface like so import flash.external.*; and only then does this command work ExternalInterface.call('console.log','Upload test FINISHED!');

Can anyone show me how to import ExternalInterface only once globally?

Thanks!

有帮助吗?

解决方案

You cannot import it only once. Well, that is only sort-of true.

You could create a singleton instance (or a static instance) elsewhere and use that, but instead of import flash.external.ExternalInterface everywhere, you would be doing something like import myCustomClass everywhere.

Since there is no gain in doing it that way, I would suggest you just import flash.external.ExternalInterface everywhere you need it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top