简体   繁体   中英

Use flex 3 module from Javascript

Is there a way to call flex module from Javascript?

The context: I'm running flex app with embedded HTML/Javascript, and I have to call flex module from this app from Javascript.

Maybe I have to make the module standalone?

I also found this approach with ExternalInterface: http://www.flexafterdark.com/docs/Flex-JavaScript

Is that the solution? Expose a callback which loads and opens the module?

Thanks

ExternalInterface is the way to do it.

If all you want to do is load and open the module, just use ExternalInterface.addCallback to create a callback to a function that loads and opens the module as you would normally.

If you need to be able to call functions on the module after it's loaded, for every method you want to be able to use from JavaScript, you can use ExternalInterface.addCallback to register it. Or you can get fancy and use describeType to get all the public methods of the module, and register them in a loop, rather than specifying them one by one.

Keep in mind that you can't pass complex objects over the ExternalInterface. Typed JS objects become generic { } objects. Functions become null.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM