• 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(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返回的信息。

  • 相关阅读:
    Legendary Items-微软2017实习生笔试第一题
    (转载)华为离职副总裁徐家骏:年薪千万的工作感悟
    【AtCoder Regular Contest 092】C.2D Plane 2N Points【匈牙利算法】
    poj 2236【并查集】
    poj 2431 【优先队列】
    poj 3280【区间dp】
    uva 10453 【回文串区间dp】
    uva 10739【基础(区间)dp】
    poj 2385【动态规划】
    poj 2229 【完全背包dp】【递推dp】
  • 原文地址:https://www.cnblogs.com/sm21312/p/4203304.html
Copyright © 2020-2023  润新知