java flash_java窗体与Flash交互

最近在研究flash,用flash去读取文件很简单,但是存储文件就很麻烦了。

因此想到用java的窗体进行交互。

下面是DJNativeSwing-SWT-1-0-3-20140708的下载链接:

http://pan.baidu.com/s/1o67eIim

基本原理是用java内嵌式开源浏览器将编译好的swf文件进行展示。

如果是windows64位系统,需要64位的swt4.3的jar包:

http://archive.eclipse.org/eclipse/downloads/drops4/R-4.3.2-201402211700/swt-4.3.2-win32-win32-x86_64.zip

在windows窗体上展示flash文件目前本人亲测可用。

另:

java与flash的数据交互据说有以下方法,尚未证明:

1.flash给swing发送消息:

ExternalInterface.call("sendNSCommand", "request", msg.toString());

这里的sendNSCommand是DJNativeSwing已经实现的方法,直接调用即可。

2.swing接收flash消息的方法:

flashPlayer.addFlashPlayerListener(newFlashPlayerListener() {public voidcommandReceived(FlashPlayerCommandEvent e) {

String cmd=e.getCommand();if(FlashCommand.EXIT.equals(cmd)) {

Application.exit();

}else if ("request".equals(cmd)) {

MessageServiceServerFlashImpl.this.processRequest((String)(e.getParameters()[0]));

}else if(FlashCommand.LOG.equals(cmd)) {

MessageServiceServerFlashImpl.this.processLog(e.getParameters());

}

}

});

flashPlayer就是DJNativeSwing里的JFlashPlayer。

3.swing给flash返回信息:

flashPlayer.invokeFlashFunction("reply", msg.toString());

4.flash处理swing返回的信息:

ExternalInterface.addCallback(("reply", onReply);

onReply就是自定义的回调函数,用来处理swing返回的信息。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值