Communication between c++ and actionscript 3

前端 未结 6 1304
暗喜
暗喜 2021-01-02 16:24

Is it possible to use any IPC mechanism for calling a c++ api from Adobe Flash actionscript? Are there any good examples?

Update: I primarily want it for desktop ap

6条回答
  •  孤独总比滥情好
    2021-01-02 16:42

    Not from the flash player, as it would very likely violate its security model. You can call C++ from the Tamarin VM, which for example mod-actionscript is doing. An option would be to pass your calls to an AS3-server, call some C++ functions there and send back the result. Another option is to cross-compile the C++ code to AVM2 using alchemy. But if you want to call C++ to access features on the client machine not available from the flash player (file system access, UDP or whatever), then there's no way.

    edit:
    Ok, I suppose there are the following options:

    • have a look at the flash.accessibility package and solve it with AS3 only
    • create a C++ daemon running in the background, which can have bidirectional communication with flash through
      • a local socket (you'd bind a port in the daemon and the flash client would connect to it) with a custom protocol
      • a LocalConnection. This looks a little better from the AS3 perspective, but requires a little hacking on the C++ side, since you need to get hold of the connection and implement the protocol (pointers here)
    • use an alternative runtime: adobe air, zinc, swhx (requires Haxe though and the "backend" is neko, but neko can easily be extended)

提交回复
热议问题