是否有可能从你的原生code返回一个结构?这是比较简单的返回一个int或一个布尔值,但你如何返回一个更复杂的结构回动作?
Is it possible to return a struct from your native code? It's relatively straight forward to return an int or a boolean but how do you return a more complex struct back to the actionscript?
推荐答案
您可以返回一个可重新psented在本地code作为FREObject $ P $的任何对象。这实际上包括任何ActionScript类或ActionScript基本数据类型。这包括诸如:INT,字符串数组,的BitmapData,ByteArray的等
You can return any object that can be represented in the native code as a FREObject. This actually includes any Actionscript class or Actionscript primitive data type. This includes things like: int, String, Array, BitmapData, ByteArray etc.
例如可以建立长度为4的回归数组中的int值0 - 3:
For example lets construct a return array of length 4 with the int values 0 - 3:
FREObject returnAnArray( FREContext cts, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject returnArray = NULL;
FRENewObject((const uint8_t*)"Array", 0, NULL, &returnArray, nil );
FRESetArrayLength( returnArray, 4 );
for ( int32_t i = 0; i < 4; i++)
{
FREObject element;
FRENewObjectFromUint32( i, element );
FRESetArrayElementAt( returnArray, i, element );
}
return returnArray;
}
要构建ActionScript类的方法有点复杂,但遵循相似的路径。这是ofcourse本机C例如,Java相当于有所不同,但仍然有可能从本机code返回复杂的对象。
The method to construct Actionscript classes is a little more complex but follows a similar path. This is ofcourse a native C example, the Java equivalent is somewhat different but still it is possible to return complex objects from the native code.
有关详细信息,有文件堆在这里:
For more information there is heaps of documentation here:
http://help.adobe.com/en_US/air/extensions/index.html
相关推荐
最新文章