我想让java应用程序调用动作脚本中的函数?
如何让 SWF 文件立即从进行实时计算的 Java 应用程序检索值(速度是必要的)。
其他形式的问题:我怎样才能 向我的网站浏览器提供即时数据 - 现在正在计算豆子 - 和我一样快 可以吗?
how can I let an SWF file to retrieve values immediately from Java application that does live calculations (Speed is a necessity).
question in other form : how can I
give my website browser immediate data
- that are bean calculated now - as fast as i
can ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设计算是在 Flash 运行的同一浏览器中的 Java 小程序中完成的。
您可以使用以下代码从小程序内调用 Javascript。 然后,此代码可以更新 Flash 动画中的值。
如果我的假设不正确,那么 Java 应用程序在哪里运行? 在客户端还是服务器上?
如果它在服务器上,那么您需要 Flash 远程处理。 我相信有几种不同的 Flash 远程处理技术。 尝试搜索 java flash 远程处理。 您可以让它每 2 秒左右调用一次服务器以获取最新数据。
如果它在客户端上运行,出于安全考虑,我怀疑您是否可以从 Flash 连接到它。 签名的 Java 小程序可以连接到任何它想要的地方。 您可以使用它检索数据,然后使用上述方法将其推送到 Flash 中。 但这将是一个疯狂的黑客。 你能用 Flex 做同样的事情吗? (我以前从未使用过 Flex)。
I'm going to assume the calculations are being done in a Java applet in the same browser where the flash is running.
You can call Javascript from within the applet using the following code. This code could then update the values in the flash animation.
If my assumption is incorrect, then where is the Java application running? On the client or server?
If it's on the server then you need Flash remoting. I believe there are a few different Flash remoting techniques. Try searching for java flash remoting. You can make it call the server every 2 seconds or so to get the latest data.
If it's running on the client I doubt you can connect to it from Flash because of security. A signed Java applet could connect anywhere it wants to. You could retrieve the data using it, then push it into Flash using the method described above. Would be a crazy hack though. Can you do the same thing with Flex? (I've never used Flex before).
如果速度至关重要,您可能希望通过某种套接字连接来实现。 通常签名的小程序或 WebStart Java 应用程序能够打开侦听套接字。 然后 Flash 应用程序将能够连接到该套接字,因此您将获得非常快速的双向通信。
不过,也有一些注意事项。
关于如何为 Java 应用程序获取证书的几个有用链接: 如何获取免费代码签名证书(俄语),类似但不太详细的英文描述。
但是,如果您能够(阅读:速度足够)使用 Java Applet <-> JavaScript <-> Flash 组合我建议充分利用它。
If the speed is crucial, you would probably want to do it via some kind of socket connection. Usually signed applet or a WebStart Java application is able to open a listening socket. Flash application then would be able to connect to this socket and as a result you will have very fast bidirectional communication.
There are some caveats however.
Couple of useful links on how to get certificate for your Java application: how to get free code signing certificate (Russian), similar but less detailed description in English.
However, if you are able (read: the speed is sufficient) to use
Java Applet <-> JavaScript <-> Flash
combination I'd advice to take advantage of it.