DJNativeSwing是flash和swing如何通信

来源:互联网 发布:c语言复合语句格式 编辑:程序博客网 时间:2024/06/05 18:20

1.flash给swing发送消息:

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


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

 

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

flashPlayer.addFlashPlayerListener(new FlashPlayerListener() {        public void commandReceived(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返回的信息。

 

原创粉丝点击