是否可以将ActionScript 3(Flex / AIR)项目打印到标准输出?

时间:2023-01-24 17:25:35

Is there any way to have a binary compiled from an ActionScript 3 project print stuff to stdout when executed?

有没有办法在执行时将ActionScript 3项目打印的二进制文件打印到stdout?

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.

从我收集的内容来看,人们一直在通过编写依赖于本地套接字连接的hacks和写入本地文件系统中的文件的AIR应用程序来解决这个限制,但这就是它 - 显然不可能使用Flash Player来自Adobe的AIR运行时。

Is there any project (e.g. based on the Tamarin code) that is attempting to implement something that would provide this kind of functionality?

是否有任何项目(例如基于Tamarin代码)试图实现能够提供此类功能的东西?

4 个解决方案

#1


9  

With AIR on Linux, it is easy to write to stdout, since the process can see its own file descriptors as files in /dev.

使用AIR on Linux,可以很容易地写入stdout,因为该进程可以将自己的文件描述符看作/ dev中的文件。

For stdout, open /dev/fd/1 or /dev/stdout as a FileStream, then write to that.

对于stdout,将/ dev / fd / 1或/ dev / stdout作为FileStream打开,然后写入。

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.

注意:请参阅此答案,了解writeUTF()和writeUTFBytes()之间的区别 - 后者将避免stdout上的乱码输出。

#2


2  

As you say, there's no Adobe-created way to do this, but you might have better luck with Zinc, it is similar to AIR but provides real OS integration of Flash-based applications. Look though the API docs, there should be something there.

正如你所说,没有Adobe创建的方法可以做到这一点,但你可能会更好运与Zinc,它类似于AIR,但提供基于Flash的应用程序的真正的OS集成。看看API文档,应该有一些东西。

#3


1  

If you are using a debug Flash Player, you can have the Flash Player log trace messages to a file on your system.

如果您使用的是调试Flash Player,则可以将Flash Player日志跟踪消息发送到系统上的文件。

If you want real time messages, then you could tail the file.

如果你想要实时消息,那么你可以拖尾文件。

More info:

http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/

mike chambers

mesh@adobe.com

#4


1  

Redtamarin seems to be able to do this (even though it's still in its infancy):

Redtamarin似乎能够做到这一点(即使它还处于起步阶段):

Contents of test.as:

test.as的内容:

import avmplus.System;
import redtamarin.version;

trace( "hello world" );
trace( "avmplus v" + System.getAvmplusVersion() );
trace( "redtamarin v" + redtamarin.version );

On the command line:

在命令行上:

$ ./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

#1


9  

With AIR on Linux, it is easy to write to stdout, since the process can see its own file descriptors as files in /dev.

使用AIR on Linux,可以很容易地写入stdout,因为该进程可以将自己的文件描述符看作/ dev中的文件。

For stdout, open /dev/fd/1 or /dev/stdout as a FileStream, then write to that.

对于stdout,将/ dev / fd / 1或/ dev / stdout作为FileStream打开,然后写入。

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.

注意:请参阅此答案,了解writeUTF()和writeUTFBytes()之间的区别 - 后者将避免stdout上的乱码输出。

#2


2  

As you say, there's no Adobe-created way to do this, but you might have better luck with Zinc, it is similar to AIR but provides real OS integration of Flash-based applications. Look though the API docs, there should be something there.

正如你所说,没有Adobe创建的方法可以做到这一点,但你可能会更好运与Zinc,它类似于AIR,但提供基于Flash的应用程序的真正的OS集成。看看API文档,应该有一些东西。

#3


1  

If you are using a debug Flash Player, you can have the Flash Player log trace messages to a file on your system.

如果您使用的是调试Flash Player,则可以将Flash Player日志跟踪消息发送到系统上的文件。

If you want real time messages, then you could tail the file.

如果你想要实时消息,那么你可以拖尾文件。

More info:

http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/

mike chambers

mesh@adobe.com

#4


1  

Redtamarin seems to be able to do this (even though it's still in its infancy):

Redtamarin似乎能够做到这一点(即使它还处于起步阶段):

Contents of test.as:

test.as的内容:

import avmplus.System;
import redtamarin.version;

trace( "hello world" );
trace( "avmplus v" + System.getAvmplusVersion() );
trace( "redtamarin v" + redtamarin.version );

On the command line:

在命令行上:

$ ./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