简体   繁体   English

使用Javascript中的flex 3模块

[英]Use flex 3 module from Javascript

Is there a way to call flex module from Javascript? 有没有办法从Javascript调用flex模块?

The context: I'm running flex app with embedded HTML/Javascript, and I have to call flex module from this app from Javascript. 上下文:我正在运行带有嵌入式HTML / Javascript的flex应用程序,并且必须从Javascript从此应用程序调用flex模块。

Maybe I have to make the module standalone? 也许我必须使模块独立?

I also found this approach with ExternalInterface: http://www.flexafterdark.com/docs/Flex-JavaScript 我还通过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. ExternalInterface是实现此目的的方法。

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. 如果您要做的只是加载并打开模块,则只需使用ExternalInterface.addCallback创建一个回调函数即可正常加载和打开模块。

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. 如果需要在模块加载后能够在模块上调用函数,对于希望从JavaScript使用的每种方法,都可以使用ExternalInterface.addCallback进行注册。 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. 或者,您可以花哨并使用describeType来获取模块的所有公共方法,并在循环中注册它们,而不是一个一个地指定它们。

Keep in mind that you can't pass complex objects over the ExternalInterface. 请记住,您不能在ExternalInterface上传递复杂的对象。 Typed JS objects become generic { } objects. 类型化的JS对象成为通用{}对象。 Functions become null. 函数变为空。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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