Domanda

Sto usando la libreria Alchemy di Flex per generare file SWC fuori C. Ho un array di byte ( buffer char senza segno [size] ) nel layer c che vorrei tornare al layer ActionScript come ByteArray . Devo scorrere attraverso l'array e chiamare esplicitamente AS3_Set su ciascun elemento o c'è un modo per restituire l'intero array C contemporaneamente?

È stato utile?

Soluzione

Questo può essere realizzato usando AS3_ByteArray_writeBytes funzione dell'API Alchemy.

Altri suggerimenti

In C, quando si ritorna dalla funzione chiamata da Flash, restituire il puntatore all'array C, in questo modo:

int * myArray = malloc(100);
//populate array...
return AS3_Array("IntType", (int)myArray);

Quindi, in Flash:

import cmodule.<c module name>.MemUser;
...
memory = new MemUser();
for (var i:int = 0; i<4;i++) { //getting a 4 uints array
    trace(memory._mru16(data[0] + i*4)); //data is the return value from C
}

Oppure usa queste funzioni per leggere ints / floats / char dall'array c (non puoi semplicemente usare ByteArray.readInt (), i numeri in c sono rappresentati in modo diverso)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top