代码之家  ›  专栏  ›  技术社区  ›  hasseg

有没有办法让ActionScript3(flex/air)项目打印成标准输出?

  •  7
  • hasseg  · 技术社区  · 16 年前

    有没有办法让一个二进制文件从一个操作脚本3项目打印材料到 标准输出 什么时候执行?

    从我收集到的资料来看,人们一直在通过编写依赖本地套接字连接的黑客程序和向本地文件系统中的文件写入的air应用程序来绕过这一限制,但这基本上就是——显然,使用Adobe的Flash播放器和air运行时是不可能的。

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

    4 回复  |  直到 12 年前
        1
  •  9
  •   Community pid    7 年前

    在Linux上使用air,很容易写入stdout,因为进程可以在/dev中将自己的文件描述符视为文件。

    对于stdout,打开 /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();
    

    注: this answer 两者之间的区别 writeUTF() writeUTFBytes() -后者将避免stdout上的输出混乱。

        2
  •  2
  •   Theo    16 年前

    正如你所说,没有一种由Adobe创建的方法可以做到这一点,但是你可能会有更好的运气 Zinc 它类似于air,但提供了基于Flash的应用程序的真正操作系统集成。虽然看 API docs ,应该有一些东西。

        3
  •  1
  •   mikechambers    16 年前

    如果您使用的是调试flash播放器,您可以让flash播放器将跟踪消息记录到系统上的一个文件中。

    如果需要实时消息,那么可以跟踪文件。

    更多信息:

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

    迈克钱伯斯

    MESH @ AdObj.com

        4
  •  1
  •   hasseg    16 年前

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

    内容 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
    
    推荐文章