问题描述
有没有办法让从 ActionScript 3 项目编译的二进制文件在执行时打印到 stdout?
据我所知,人们一直在通过编写依赖本地套接字连接的 hacks 和写入本地文件系统中的文件的 AIR 应用程序来绕过这个限制,但这几乎是不可能的 - 这显然是不可能的Adobe 的 Flash Player 和 AIR 运行时.
是否有任何项目(例如基于 Tamarin 代码)试图实现可提供此类功能的东西?
使用 Linux 上的 AIR,很容易写入标准输出,因为进程可以将自己的文件描述符视为/dev 中的文件.
对于标准输出,打开 /dev/fd/1
或 /dev/stdout
作为 FileStream
,然后写入.>
示例:
var stdout : FileStream = new FileStream();stdout.open(new File("/dev/fd/1"), FileMode.WRITE);stdout.writeUTFBytes("test\n");标准输出.close();
注意:请参阅this answer writeUTF()
和 writeUTFBytes()
之间的区别 - 后者将避免 stdout 上的乱码输出.
Is there any way to have a binary compiled from an ActionScript 3 project print stuff to stdout when executed?
From what I've gathered, people have been going around this limitation by writing hacks that rely on local socket connections and AIR apps that write to files in the local filesystem, but that's pretty much it -- it's obviously not possible with the Flash Player and AIR runtimes from Adobe.
Is there any project (e.g. based on the Tamarin code) that is attempting to implement something that would provide this kind of functionality?
With AIR on Linux, it is easy to write to stdout, since the process can see its own file descriptors as files in /dev.
For stdout, open /dev/fd/1
or /dev/stdout
as a FileStream
, then write to that.
Example:
var stdout : FileStream = new FileStream();
stdout.open(new File("/dev/fd/1"), FileMode.WRITE);
stdout.writeUTFBytes("test\n");
stdout.close();
Note: See this answer for the difference between writeUTF()
and writeUTFBytes()
- the latter will avoid garbled output on stdout.
这篇关于有什么方法可以将 ActionScript 3 (Flex/AIR) 项目打印到标准输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!