有什么方法可以将 ActionScript 3 (Flex/AIR) 项目打印到标准输出吗?
-
09-06-2019 - |
题
有没有办法让 ActionScript 3 项目编译的二进制文件打印出来 标准输出 什么时候执行?
据我所知,人们一直在通过编写依赖于本地套接字连接的 hack 以及写入本地文件系统中的文件的 AIR 应用程序来绕过此限制,但仅此而已 - 这对于 Flash Player 来说显然是不可能的以及 Adobe 的 AIR 运行时。
有没有什么项目(例如基于 Tamarin 代码)正在尝试实现提供此类功能的东西?
解决方案
使用 Linux 上的 AIR,可以轻松写入 stdout,因为进程可以将其自己的文件描述符视为 /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");
stdout.close();
笔记: 看 这个答案 对于之间的差异 writeUTF()
和 writeUTFBytes()
- 后者将避免标准输出上的乱码输出。
其他提示
如果您使用的是调试 Flash Player,则可以让 Flash Player 将跟踪消息记录到系统上的文件中。
如果您想要实时消息,那么您可以尾随该文件。
更多信息:
http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/
迈克·钱伯斯
mesh@adobe.com
红木素 似乎能够做到这一点(尽管它仍处于起步阶段):
内容 test.as
:
import avmplus.System;
import redtamarin.version;
trace( "hello world" );
trace( "avmplus v" + System.getAvmplusVersion() );
trace( "redtamarin v" + redtamarin.version );
在命令行上:
$ ./buildEXE.sh test.as
test.abc, 243 bytes written
test.exe, 2191963 bytes written
test.abc, 243 bytes written
test.exe, 2178811 bytes written
$ ./test
hello world
avmplus v1.0 cyclone (redshell)
redtamarin v0.1.0.92
不隶属于 StackOverflow