Question

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!

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top