A: 可將將數據塊的首指針地址返回給AS以讀取其中數據,具體看下面代碼:
比如說我們在C裡創建了一個整型數組,要返回給AS:
static AS3_Val myfun(void *self, AS3_Val args){ int buffer[4] = {1, 2, 3, 4}; return AS3_Array("IntType, AS3ValType", AS3_Int(4), AS3_Ptr(buffer)); }然後在AS裡進行讀取:
var loader:CLibInit = new CLibInit(); var clib:Object = loader.init(); var rs:Array = clib.myfun(); var len:init = rs[0]; var ptr:uinit = rs[1]; var ns:Namespace = new Namespace("cmodule.ModuleName"); var memory:ByteArray = (ns::gstate).ds; memory.position = ptr; var i:int; for(i = 0; i < len; i ++){ trace(memory.readInt()); }
0 意見