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?
相关问题
- javah not able to find android classes
- garbage collection best practices
- How to load flex swf from flash?
- FlashDevelop Haxe (Flash) debugger
- Detecting user's camera settings
相关文章
- Native hooking in Android Client
- Are there any benefits when using final in AS3?
- Trace on Chrome/Browser console
- as3 ByteArray to Hex (binary hex representation)
- About Collision detection alghorithms in AS3
- How to upload BitmapData to a server (ActionScript
- React native create rectangle bottom, plus half re
- Manage resources to minimize garbage collection ac
Return value from finished process is limited to an
int
. But you can write data to stdout and read it in your AIR application:StandardOutput implements IDataOut interface like ByteArray, so you can read any basic types from it. See also NativeProcess docs.
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.
For example lets construct a return array of length 4 with the int values 0 - 3:
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
The accepted answer is not accurate for your original question. You want to return a struct... well you can't actually do that but the proper way to do this is to write your native struct/class as an actionscript class, then use the ExtensionContext object to associate your native struct or class pointer with your context. Then when you can write methods into your struct/class that will directly interface with methods and properties within. If any of the methods within return another struct or class, repeat the process recursively.
Java examples
Returning Array
More info http://help.adobe.com/en_US/air/extensions/WS982b6f491d178e6d6565d9b1132a79a012f-7ff8.html
Also consider using JSON