Hi, I'm having troubles with getting the output from a native process in my AIR application. I'm using Flash CS5, AIR 3 SDK and I've exported using Windows installer with extendedDesktop profile.

So, this is my AS3 Code, I just put it into Flash's Action window, for testing:
Actionscript Code:
import flash.events.MouseEvent;
import flash.desktop.NativeProcess;
import flash.filesystem.File;
import flash.desktop.NativeProcessStartupInfo;
import flash.events.ProgressEvent;

button1.addEventListener(MouseEvent.CLICK, onClick);

var process:NativeProcess;

function onClick(e:MouseEvent):void
{
    if (NativeProcess.isSupported)
    {
        log.appendText("NativeProcess supported.\n");
        launchNativeProcess();
    }
    else
    {
        log.appendText("NativeProcess not supported.\n");
    }
}

function launchNativeProcess():void
{
    var file:File = new File();
    file.resolvePath("NativeStdout.exe");
    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
    nativeProcessStartupInfo.executable = file;
    process = new NativeProcess();
    process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
    process.start(nativeProcessStartupInfo);

}

function onOutputData(e:ProgressEvent):void
{
    log.appendText(process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable));
    launchNativeProcess();
}

And this is my C code:
Actionscript Code:
#include <stdlib.h>
#include <stdio.h>

int my_itoa(int val, char*buf);

int main()
{
    char buffer[10];
    int num = 512;
    my_itoa(num, buffer);
    fwrite(buffer, 3, 1, stdout);

    return 0;
}


int my_itoa(int val, char* buf)
{
    const unsigned int radix = 10;

    char* p;
    unsigned int a;        //every digit
    int len;
    char* b;            //start of the digit char
    char temp;
    unsigned int u;

    p = buf;

    if (val < 0)
    {
        *p++ = '-';
        val = 0 - val;
    }
    u = (unsigned int)val;

    b = p;

    do
    {
        a = u % radix;
        u /= radix;

        *p++ = a + '0';

    } while (u > 0);

    len = (int)(p - buf);

    *p-- = 0;

    //swap
    do
    {
        temp = *p;
        *p = *b;
        *b = temp;
        --p;
        ++b;

    } while (b < p);

    return len;
}

Any help would be great. If I use the native application alone, it still prints the number onto the console, but somehow the NativeProcess can't pick it up.